THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 14/09/2011 at 19:42, xxxxxxxx wrote:
Cinema 4D Version: 13
Platform: Windows ; Mac ;
Language(s) : C++ ;
I have a sweep Nurbs under which place a cubic spline and a circle spline. Then, I make the sweep nurbs editable via SendModelingCommand(MCOMMAND_CURRENTSTATETOOBJECT, mcd);
The result is that the main object has two children object which are the caps that were created. What I woiuld like to do then , is connect the caps to the main body and then optimize that to connect the caps to the main body. This is of course all via code and not manually.
Could someone explain to me how I would do this?
I understand how to run optimize via SendModelingCOmmand.. and I have found that the Connect + Delete command can be called via CallCommand(16768); But I can't seem to make it work.. When I add the call command, c4d crashes.
Here is the code I am trying to use.
//CONVERT TO POLYGON OBJECT
mcd.op = objsweep;
mcd.mode = MODELINGCOMMANDMODE_ALL;
mcd.mode = MODIFY_ALL;
mcd.doc = doc;
BaseObject *res = static_cast<BaseObject*>(mcd.result->GetIndex(0));
PolygonObject *polyObj = (PolygonObject * )res;
if(!polyObj) return NULL;
CallCommand(16768); //Connect and Delete
// MESH OPTIMIZE
mcd3.bc = &bc3;
mcd3.op = polyObj;
mcd3.mode = MODELINGCOMMANDMODE_ALL;
mcd3.mode = MODIFY_ALL;
mcd3.doc = doc;
Any help you could offer would be great.
On 15/09/2011 at 01:28, xxxxxxxx wrote:
From where do you call this, from GetVirtualObjects?
On 15/09/2011 at 03:29, xxxxxxxx wrote:
Woops, sorry! Yes, it is called from GetVirtualObjects()
On 15/09/2011 at 06:47, xxxxxxxx wrote:
I've just been through this very same thing so I feel your pain. I don't think you can use CallCommand from GVO. What I did was take the object returned from the CurrentStateToObject and did another SendModelingCommand on it using MCOMMAND_JOIN. Since that also returns a new object you can delete the object returned from the first SendModelingCommand call ('res' in your case) and return the connected one. Or do an optimize on it then return it (I didn't need the optimized version).
Seems to work for me, anyway.
On 15/09/2011 at 08:45, xxxxxxxx wrote:
CallCommand within GetVirtualObjects is fatal and forbidden. As suggested use SendModelingCommand to join and optimize objects.
On 15/09/2011 at 08:49, xxxxxxxx wrote:
Just to add, always keep in mind that GetVirtualObjects sole purpose is to return an object or a group of objects. Every change to the document or the interface is strictly forbidden. If you think about it that it runs in a multithreaded context it makes sense.
On 15/09/2011 at 09:15, xxxxxxxx wrote:
Thanks guys. I will do that.
@Matthias. Thanks for the Info. That makes perfect sense. GVO and I have had a love hate relationship for a while now. HAHA I am always trying to push her beyond her limits.. LOL
On 16/09/2011 at 08:30, xxxxxxxx wrote:
Remember, that to get around some of the limitations due to thread safety, you can sometimes use a separate document, held in memory only, to do your building. I don't know what the efficiency of that method is, though. It's probably dependent on how many calls or calculations are needed to perform the task.