THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 03/09/2011 at 08:42, xxxxxxxx wrote:
Cinema 4D Version: R12
Platform: Windows ;
Language(s) : C++ ;
I have a generator plugin. In GetVirtualObjects I want to do a CurrentStateToObject on a sweep nurbs, because I need a polygon object to work with. Here's the code I'm using:
BaseObject *res = NULL, *newop = NULL;
AutoAlloc<BaseDocument>tdoc; // temporary document
newop = static_cast<BaseObject*>(lnk->GetClone(COPYFLAGS_0, NULL)); // 'lnk' is a sweep nurbs object
tdoc->InsertObject(newop, NULL, NULL, FALSE);
cd.doc = tdoc;
cd.op = newop;
cd.mode = MODELINGCOMMANDMODE_ALL;
cd.bc = &bcmcd;
res = static_cast<BaseObject*>(cd.result->GetIndex(0));
This all works fine, as long as the sweep nurbs has a contour spline and a path spline in the usual way. However, if I put a Mograph tracer object in as the path spline, generating splines using a particle emitter, it fails. Instead of returning a polygon object, for some reason CSTO returns a null object with just the contour spline in it. That's even though there's a perfectly good object in the viewport, and if I do a CSTO on it manually using the Objects menu in the OM, it returns the polygon object I would expect.
I'm obviously doing something wrong but I can't see what. Can anyone see why this isn't working? I've tried doing a CSTO on the tracer object first then inserting it back into the temporary document, but all I get is a crash.
Would really appreciate some help with this one.
On 06/09/2011 at 01:51, xxxxxxxx wrote:
Sorry to bump this but does no-one have any thoughts on how to do this? I've tried every combination of cloning the object, cloning the document, all the options in SendModelingCommand, still nothing. All I get returned is a null.
On 06/09/2011 at 09:21, xxxxxxxx wrote:
Well, I finally solved this one. For anyone else ever trying to do the same thing, the solution is very simple. Instead of creating a new document, just clone the original object (the sweep nurbs in this case), DON'T insert it into any document, then do the CSTO on the clone. You can then use the returned object to access its points/polygon data.
Since you haven't changed anything in the original document, this is legal and all you need to do is delete the clone as well as the object returned from the SendModelingCommand call before exiting.
On 07/09/2011 at 00:52, xxxxxxxx wrote:
Thanks for posting your solution!