setting ALIGNTOSPLINETAG_LINK ?
On 11/04/2016 at 12:39, xxxxxxxx wrote:
Cinema 4D Version: r14+
Platform: Windows ;
Language(s) : C++ ;
Hi there, after some absence from coding i am struggling setting the ALIGNTOSPLINETAG_LINK of tag.
this is the code (where step is just some other BaseObject created in a loop) :
BaseObject* splineLink = static_cast<BaseObject*>((BaseObject* )bc->GetObjectLink(USERSPLINE, doc)->GetClone(COPYFLAGS_0, NULL)); splineLink->InsertUnder(main); BaseTag* alignToSpline = step->MakeTag(Taligntospline); alignToSpline -> SetParameter(DescID(ALIGNTOSPLINETAG_LINK),GeData(splineLink),DESCFLAGS_SET_0); alignToSpline -> SetParameter(DescID(ALIGNTOSPLINETAG_TANGENTIAL),GeData(useTangent),DESCFLAGS_SET_0); alignToSpline -> SetParameter(DescID(ALIGNTOSPLINETAG_POSITION),GeData((1.0/(max-1))*current),DESCFLAGS_SET_0);
this results in that the tangent rotation is working, but the positioning only works after converting the object to an editable one.
any ideas what i may be missing?
On 12/04/2016 at 02:40, xxxxxxxx wrote:
I quickly tried tested your code in a simple Python script and it worked out of the box.
So I guess, your issue must have something to do with wither surrounding code or the place you are using this code in. Can you give us some more details?
A quick note on the first two lines (even if I assume, that you probably shortened the code for posting it here) :
You are directly dereferencing the link you pull out of the BaseContainer. This is quite dangerous, the result may be a nullptr.
Then you clone the referenced object and again dereference it directly in order to insert it into the document. As cloning involves memory allocations, this can fail as well and a nullptr check is needed, too.
Of course this has nothing to do with your actual problem, just wanted to mention it.
On 12/04/2016 at 05:06, xxxxxxxx wrote:
hm, i guess posting the whole code would be a bit too much lines.
i have however tried disabeling fragments whereever the spline was referenced or added to the dependency list, etc. maybe i need to create a fresh object to sort things out step by step. i was trying to change/add something to an existing older plugin.
btw, you are right about the referenced object. it is checked previously.