I'm adjusting the code of my plugins to make then work in R21.
One of them creates, internally, a Sweep that is then converted to a polygonal object through a SendModelingCommand, set to CurrentStateTo Object.
The plugin works fine until R20, but in R21, the SendModelingCommand (set to CSTO), returns a Null.
Did anything changed and needs to be done differently?
Solved CurrentStateToObject returning Null
This is my code
...
version_number=c4d.GetC4DVersion()
main_sweep=c4d.BaseObject(c4d.Osweep)
main_sweep[c4d.SWEEPOBJECT_GROWTH]=completeness
main_sweep[c4d.SWEEPOBJECT_SPLINESCALE]=spline_scale
main_sweep[c4d.SWEEPOBJECT_ROTATE]=twist1
if version_number<21000:
main_sweep[c4d.CAP_START]=close_start
main_sweep[c4d.CAP_END]=close_end
main_sweep[c4d.CAP_TYPE]=2
else:
main_sweep[c4d.CAPSANDBEVELS_CAP_ENABLE_START]=close_start
main_sweep[c4d.CAPSANDBEVELS_CAP_ENABLE_END]=close_end
main_sweep[c4d.CAPSANDBEVELS_CAP_TYPE]=2
# insert the path inside the SweepNURBS
new_spline.InsertUnder(main_sweep)
# insert the profile inside the SweepNURBS
main_profile=c4d.BaseObject(c4d.Osplinerectangle)
main_profile[c4d.PRIM_RECTANGLE_WIDTH]=profile_size
main_profile[c4d.PRIM_RECTANGLE_HEIGHT]=profile_size
main_profile.InsertUnder(main_sweep)
the_mode=c4d.MODELINGCOMMANDMODE_ALL
if version_number<21000:
the_mode=c4d.MODIFY_ALL
result=utils.SendModelingCommand(command=c4d.MCOMMAND_CURRENTSTATETOOBJECT,list=[main_sweep],mode=the_mode,bc=c4d.BaseContainer(),doc=doc)
The result variable returns this:
[<c4d.BaseObject object called 'Sweep/Null' with ID 5140 at 0x149102450>]
It is simply a Null without any children.
I know that the Sweep is fine, because when I return just the Sweep, I get the correct Sweep. But I need it be a polygonal object, not a Generator.
What could be happening?
Oh, another information that could be important.
This is an Object plugin. And, when testing, if I simply return the Sweep object, it generates the correct mesh (although, I require a polygonal mesh because I still have to do some operations on the faces).
But, if I press the C key, the Object plugin generates a simple Sweep Generator, without any children.
Also, replacing the MCOMMAND_CURRENTSTATETOOBJECT with MCOMMAND_MAKEEDITABLE, I get this error:
ReferenceError: the object 'c4d.BaseObject' is not alive
Hello,
this is currently a bug, already fixed and will ship with the next update R21.1 (SP1).
The only work around is to create a temporary document, insert the sweep there, run the command there.
Also, replacing the MCOMMAND_CURRENTSTATETOOBJECT with MCOMMAND_MAKEEDITABLE, I get this error:
ReferenceError: the object 'c4d.BaseObject' is not alive
I cannot reproduce this, can you share the whole code ?
Cheers,
Manuel
MAXON SDK Specialist
It is working now. However, after a while, I got an error that it looked like a memory leak or something similar.
I'm using c4d.documents.IsolateObjects to create a new temporary document.
Do I need to delete that new document, after performing the MCOMMAND_CURRENTSTATETOOBJECT?
hello,
what is the error message ?
the document should be free at the end of the scope if no reference is pointing to it.
Cheers,
Manuel
MAXON SDK Specialist
hello @rui_mac without futher information i'll change this thread as resolved tomorrow.
MAXON SDK Specialist