How do I get geometry data for parametric objects?

On 16/03/2015 at 04:27, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   R14 
Platform:   Windows  ;   
Language(s) :   C.O.F.F.E.E  ;

Hey there,

I'm writing a filter plugin in COFFEE to export models into a text format.
I've managed to get a working export script for PolygonObjects, but the scenes I want to export might contain other types of objects (parametric primitives, *nurbs, instances, arrays, ...). My question is: how do I go about exporting those?
I need to be able to read point and polygon data for these objects. Ideally, I'd like to be able to get a list of PolygonObjects for each of them.
I have found the SendModelingCommand  method in the doc, but I don't want my export script to modify the scene. It's not acceptable to have all my primitives and special objects converted to geometry in the c4d file after the export.

Any idea ?

Thanks!_<_mytubeelement_>_<mytubeelement =""loadBundle":true" ="relayPrefs" id="myTubeRelayElementToTa_<_mytubeelement_>_nt>

On 16/03/2015 at 05:25, xxxxxxxx wrote:

You will need to call SendModelingCommand most likely with CURRENTSTATETOOBJECT. You can (and should) add your modifications to a dummy document not attached to the document list.  Any command that changes the object directly (SUBDIVIDE) will need the object cloned (copied) first and the command acting upon the clone.  Then export the objects from the dummy document which leaves the original document untouched.

On 16/03/2015 at 10:02, xxxxxxxx wrote:


as said in the other topic, COFFEE is outdated. If you are starting to write a new plugin you might want to take a look Python or C++. There you can get the polygon cache of objects using GetCache().

Best wishes,

On 16/03/2015 at 10:04, xxxxxxxx wrote:

I agree with Sebastian here.  I was going to mention using Python if you already know it or are comfortable with learning it.

On 16/03/2015 at 10:27, xxxxxxxx wrote:

Hi, thanks for the fast replies.
I needed to be able to export in a certain format fast, so I didn't really have time to learn Python or to struggle with C++ this time ;) I'll try to learn Python for the next. Coffee was good because the language had a very classical syntax and basically required no learning at all, one would just focus on learning the API.

Anyways, I did as you said: I copy all of the objects into a dummy document and convert them with SendModelingCommand.
I have one last problem however: instances.

I can't copy a Instance object _<_mytubeelement_>_<mytubeelement =""loadBundle":true" ="relayPrefs" id="myTubeRelayElementToTa_<_mytubeelement_>_nt> because it loses its reference. One workaround I can think of is to find the object referenced by the instance, make a copy of it, and copy the instance's matrix.
The problem I have however, is I can't figure out how to get the object referenced by the instance.
I found the GetObject method in BaseContainer, but I don't know what ID I should pass as argument, I can't find any relevant constant.
Any idea?

Thanks for your help!

On 16/03/2015 at 13:04, xxxxxxxx wrote:

Nevermind, I'm also losing reference to material.
I'll try and find another way to convert models into my format._<_mytubeelement_>_<mytubeelement =""loadBundle":true" ="relayPrefs" id="myTubeRelayElementToTa_<_mytubeelement_>_nt>

On 16/03/2015 at 14:56, xxxxxxxx wrote:

For instances, you will need to check the link in the Instance object to get to the original object (and you will need to maintain a proper link to it during conversion).  Not sure how CURRENTSTATETOOBJECT works with them exactly and even less with COFFEE.

If I remember, tags are either all stacked neatly on a parent Null object of the SendModelingCommand() result or you need to clone them onto the resulting objects from the original.  Materials are not carried along - you need to do that manually (unfortunately).

For the sake of testing, I would clone the objects into the working document (pre-saved if you are using a test document in the process) so that you can see at each step what each command does.  Results vary depending upon the hierarchy, types of objects (modifiers, generators, etc.), and splines need some special consideration if they aren't being used as guides in generator objects.

Basically, clone the object, insert into the working document (don't forget cloneobj->Msg(MSG_UPDATE) and EventAdd() to refresh C4D), call your SendModelingCommand().  If the result isn't directly on the object (like CURRENTSTATETOOBJECT), add the result to the document and repeat refresh.  This way, you see how instances, materials/textures, tags, and so on are being converted and maintained.