Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.
Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 05/03/2010 at 05:35, xxxxxxxx wrote:
User Information: Cinema 4D Version: Platform: Mac OSX ; Language(s) : C.O.F.F.E.E ;
--------- Is there any way, in COFFEE, to perform a "Current State to Object" to a an object without it having to be selected in the editor? Also, I would like that the resulting object not to be sent to the editor. What I want is to create a clone of an object, apply it a "Current State to Object" command, get a polygonal object out of it (I intend to access its points and polygonal coordinates just for reference) and then throw away that polygonal object (and the clone). Is this at all possible in COFFEE or just in C++?
Rui Batista
On 05/03/2010 at 06:08, xxxxxxxx wrote:
Sure, use SendModelingCommand() Cheers, Jack
On 05/03/2010 at 06:16, xxxxxxxx wrote:
I know that command, Jack. I have already used it before. However, it requires that an object is selected in the editor (can be done with object->SetBit(BIT_AOBJ); I know). Also, it returns a polygonal object in the editor, also. What I want is a way to simply point to an object in my document (can be the actual object or a clone of it, if required) and I want to get an object that is not placed in the editor. I just want a reference to the internally generated object. Than I would access the point and polygon list of that internally generated object and then I would throw it away. All this without disturbing my object list. What was selected before would still be selected after executing my code.
On 05/03/2010 at 08:16, xxxxxxxx wrote:
I managed it by clone the object and insert it into a new temp document. Do the calculation in the temp document and then Kill the temp document. Maybe not to efficient for an expression thou, but you can try.
Cheers Lennart
On 05/03/2010 at 08:35, xxxxxxxx wrote:
That may be a nice solution. But how do I create a new document in COFFEE?
var new_doc=new(BaseDocument);
and then what!?
On 05/03/2010 at 08:51, xxxxxxxx wrote:
My studio is shut down a couple of days, but I'll look up what I did as soon as I can, probably next week.
I think you should look for "InsertDocument()". It becomes the first active doc. (Mark your present doc first so you can go back to using doc->GetNext() && the name of it maybe.)
On 05/03/2010 at 15:45, xxxxxxxx wrote:
This is what I can come up with from memory (as a command script). I'd guess you would have a second "scrap" document open if you want to run an expression.
This works at least in R11.5 but I know I had some issues inserting an object (the clone) into an empty document (the temp document). Then I Allocated and inserted a "dummy" Null object from within the temp document before inserting my clone from the source document.
var thisdoc = GetActiveDocument(); var opA = thisdoc->GetFirstObject(); var opclone = opA->GetClone(CL_NO_HIERARCHY); CallCommand(12094); //Create new temp document var tempdoc = GetFirstDocument(); // Thenew doc is first on the list tempdoc->InsertObject(opclone,NULL,NULL); // Insert our clone var bc = new(BaseContainer); SendModelingCommand(MCOMMAND_MAKEEDITABLE,tempdoc,opclone,bc,MODIFY_ALL); // Make it an editable, point object var amount = tempdoc->GetFirstObject()->GetPointCount(); // Do something KillDocument(tempdoc); // Done, Kill the temp document thisdoc->SetBit(BIT_ADOC); // Make our original document the active one println(amount); // Print our points
On 06/03/2010 at 06:54, xxxxxxxx wrote:
I still don't see why you need a second document for that. It definitely works even when the source object is not selected:
MyMenuPlugin::Execute(doc) { var bc = new(BaseContainer); bc->SetData(MDATA_CURRENTSTATETOOBJECT_INHERITANCE, TRUE); bc->SetData(MDATA_CURRENTSTATETOOBJECT_KEEPANIMATION, TRUE); var op = doc->GetFirstObject(); var res = SendModelingCommand(MCOMMAND_CURRENTSTATETOOBJECT, doc, op, bc, MODIFY_ALL); if (res) { TextDialog("Seems to have worked.", DLG_OK); EventAdd(EVENT_FORCEREDRAW); } else { TextDialog("Did not work.", DLG_OK); } }
This code works and creates a polygonized version of the first object in the scene, even if it's not selected. But there's something funny. The result object is inserted into the document automatically. If I try creating a clone of the object first, then performing the modeling command, and then inserting the result object into the document, nothing gets polygonized. I just get a clone of the unchanged original object. Strange...
MyMenuPlugin::Execute(doc) { var bc = new(BaseContainer); bc->SetData(MDATA_CURRENTSTATETOOBJECT_INHERITANCE, TRUE); bc->SetData(MDATA_CURRENTSTATETOOBJECT_KEEPANIMATION, TRUE); var op = doc->GetFirstObject(); var clone = op->GetClone(CL_NO_HIERARCHY); var res = SendModelingCommand(MCOMMAND_CURRENTSTATETOOBJECT, doc, clone, bc, MODIFY_ALL); if (res) { TextDialog("Seems to have worked.", DLG_OK); doc->InsertObject(clone, NULL, NULL); EventAdd(EVENT_FORCEREDRAW); } else { TextDialog("Did not work.", DLG_OK); } }
So, you could in fact use the first code from this posting, and remove the newly created object (which also gets magically selected ) from the document and continue working with it. Cuold be faster than creating dummy documents etc.. Cheers, Jack
On 06/03/2010 at 07:15, xxxxxxxx wrote:
I will give it a try. However it should not work for that I intend to do because I need to keep my document in the same state as it was before running the Current State to Object and all the other stuff. With the same state I mean that I need to keep the same selections it had.
On 08/03/2010 at 01:03, xxxxxxxx wrote:
Can't you just store the initial selection state before you do anything, and then later restore it? Cheers, Jack