Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    MCOMMAND_SELECTALL and MCOMMAND_SELECTINVERSE not working?

    Cinema 4D SDK
    python 2024 windows
    2
    3
    541
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      datamilch
      last edited by

      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
      

      mcommand select test 01.c4d

      i_mazlovI 1 Reply Last reply Reply Quote 0
      • i_mazlovI
        i_mazlov @datamilch
        last edited by

        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

        MAXON SDK Specialist
        developers.maxon.net

        D 1 Reply Last reply Reply Quote 0
        • D
          datamilch @i_mazlov
          last edited by

          @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.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post