MCOMMAND_SELECTALL and MCOMMAND_SELECTINVERSE not working?
-
hi there,
i was shifting around some selections and noticed that some modeling commands seem to have no effect.
MCOMMAND_SELECTALL
MCOMMAND_SELECTINVERSE
i realize i can use SelectAll on the BaseSelect. and i could surely build a loop, to invert the selection. but why are these commands there? they even return true, despite doing nothing.this is my code and a demo file:
import c4d doc: c4d.documents.BaseDocument op: c4d.BaseObject def main() -> c4d.BaseObject: obj = op[c4d.ID_USERDATA,1].GetClone() bs_points = obj.GetPointS() #bs_points.SelectAll( obj.GetPointCount()-1 ) # will select all points c4d.utils.SendModelingCommand( c4d.MCOMMAND_SELECTALL, [ obj ], c4d.MODELINGCOMMANDMODE_POINTSELECTION, doc=doc) # not working c4d.utils.SendModelingCommand( c4d.MCOMMAND_SELECTSHRINK, [ obj ], c4d.MODELINGCOMMANDMODE_POINTSELECTION, doc=doc) c4d.utils.SendModelingCommand( c4d.MCOMMAND_SELECTINVERSE, [ obj ], c4d.MODELINGCOMMANDMODE_POINTSELECTION, doc=doc) # not working bc = c4d.BaseContainer() bc[c4d.MDATA_CONVERTSELECTION_LEFT] = 0 # 0 = points bc[c4d.MDATA_CONVERTSELECTION_RIGHT] = 1 # 1 = edges bc[c4d.MDATA_CONVERTSELECTION_TOLERANT] = False # tolerant conversion res = c4d.utils.SendModelingCommand( c4d.MCOMMAND_CONVERTSELECTION, [ obj ], bc=bc, doc=doc) res = c4d.utils.SendModelingCommand( c4d.MCOMMAND_EDGE_TO_SPLINE, [ obj ], doc=doc) return obj
-
Hi @datamilch,
The c4d.utils.SendModelingCommand has an optional argument bc that contains settings that you pass to the command. Default value for bc is None, which is not the same as empty c4d.BaseContainer. Some commands tolerate bc=None, some require it to be present even if it's empty. The following lines work as expected:
c4d.utils.SendModelingCommand(c4d.MCOMMAND_SELECTALL, [obj], c4d.MODELINGCOMMANDMODE_POINTSELECTION, c4d.BaseContainer(), doc) c4d.utils.SendModelingCommand(c4d.MCOMMAND_SELECTSHRINK, [obj], c4d.MODELINGCOMMANDMODE_POINTSELECTION, c4d.BaseContainer(), doc)
Please also note, that in your code snippet you clone the object and perform some commands on it, but you never insert it back to document. Also note that some modeling commands require document context, hence in such cases the objects are additionally required to be inserted into a document.
Cheers,
Ilia -
@i_mazlov Thanks!
makes sens. seems i only used the forgiving commands until now.the code is run in a python generator. so by returning the object, it will be inserted into the scene.