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

    CurrentStateToObject returning Null

    Cinema 4D SDK
    3
    10
    1.1k
    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.
    • R
      rui_mac
      last edited by

      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?

      1 Reply Last reply Reply Quote 0
      • S
        s_bach
        last edited by

        Hello,

        can you share your code?

        best wishes,
        Sebastian

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        1 Reply Last reply Reply Quote 0
        • R
          rui_mac
          last edited by

          Will do, as soon as I get home.
          Thank you.

          1 Reply Last reply Reply Quote 0
          • R
            rui_mac
            last edited by

            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?

            1 Reply Last reply Reply Quote 0
            • R
              rui_mac
              last edited by

              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.

              1 Reply Last reply Reply Quote 0
              • R
                rui_mac
                last edited by

                Also, replacing the MCOMMAND_CURRENTSTATETOOBJECT with MCOMMAND_MAKEEDITABLE, I get this error:

                ReferenceError: the object 'c4d.BaseObject' is not alive

                1 Reply Last reply Reply Quote 0
                • ManuelM
                  Manuel
                  last edited by

                  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

                  MAXON Registered Developer

                  1 Reply Last reply Reply Quote 0
                  • R
                    rui_mac
                    last edited by

                    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?

                    1 Reply Last reply Reply Quote 0
                    • ManuelM
                      Manuel
                      last edited by Manuel

                      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

                      MAXON Registered Developer

                      1 Reply Last reply Reply Quote 0
                      • ManuelM
                        Manuel
                        last edited by

                        hello @rui_mac without futher information i'll change this thread as resolved tomorrow.

                        MAXON SDK Specialist

                        MAXON Registered Developer

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