Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python 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

    Current State To Object in Python

    Scheduled Pinned Locked Moved PYTHON Development
    3 Posts 0 Posters 418 Views
    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.
    • H Offline
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 30/10/2011 at 09:15, xxxxxxxx wrote:

      Hey there!

      Bit stuck on how to execute this in order to bake something with a mograph displacer on it into geometry.

      Here's what I've got thus far. It mentions something in the docs about potentially needing to act on a duplicate of the object but then doesn't really elaborate. Any help much appreciated!

      Cheers, sCam

        
      import c4d   
      from c4d import gui   
      from c4d import utils   
      from c4d import documents   
        
      def main() :   
        
          document = documents.GetActiveDocument()   
          settings = c4d.BaseContainer()   
        
          obj = document.SearchObject("picture source")   
        
          return_value = utils.SendModelingCommand(   
               command = c4d.MCOMMAND_CURRENTSTATETOOBJECT,   
               list = [obj],   
               mode=c4d.MODELINGCOMMANDMODE_ALL,   
               bc=settings,   
               doc = document)   
                  
          print return_value   
        
      if __name__=='__main__':   
          main()   
      
      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 30/10/2011 at 12:10, xxxxxxxx wrote:

        Hi, I assume this is a standard script and not part of a Python Generator, correct?
        The code you posted works fine. Just insert the returned object in the document and update it:

        import c4d
        from c4d import gui
        from c4d import utils
        from c4d import documents
          
        def main() :
            document = documents.GetActiveDocument()
            settings = c4d.BaseContainer()
            obj = document.SearchObject("picture source")
            return_value = utils.SendModelingCommand(
                 command = c4d.MCOMMAND_CURRENTSTATETOOBJECT,
                 list = [obj],
                 mode=c4d.MODELINGCOMMANDMODE_ALL,
                 bc=settings,
                 doc = document)
            
            #NEW----
            if return_value:
                doc.InsertObject(return_value[0]) #return_value is a list in this case
                c4d.EventAdd()
            #NEW----
          
          
        if __name__=='__main__':
            main()
        
        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 01/11/2011 at 00:26, xxxxxxxx wrote:

          Worked great! Thanks for your help - much appreciated!

          Cheers, sCam

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