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
    • Recent
    • Tags
    • Users
    • Login

    Create editable sphere from Py-Generator? [SOLVED]

    Scheduled Pinned Locked Moved PYTHON Development
    4 Posts 0 Posters 365 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

      On 11/10/2014 at 08:36, xxxxxxxx wrote:

      I have been searching for some time but cannot find a simple answer to this that actually works for the Python Generator:

      How can the Python Generator create a sphere and then make it editable, so it is no longer a primitive?

      Thanks,
      S

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        On 11/10/2014 at 16:38, xxxxxxxx wrote:

        Hi.
         
        as far as I know, the Python generator don´t let you insert a converted polygonal version, offhandedly.
        You can write your own Sphere object or use this workaround;
        The generator has some userdata to manipulate the sphere and a child object which stays every time updated.
        Like this example:

          
        import c4d  
        from c4d import utils  
          
          
        def main() :  
            
          obj=c4d.BaseObject(c4d.Osphere)  
            
          # check if there is allready userdata for the python generator  
          # just to begin with something; insert userdata for the radius of the sphere  
          if  op.GetUserDataContainer() == []:  
              radius=c4d.GetCustomDataTypeDefault(c4d.DTYPE_REAL)  
              radius[c4d.DESC_NAME] = "radius"     
              op.AddUserData(radius)  
              radiusvalue = op[c4d.ID_USERDATA,1]  
          else:  
              radiusvalue = op[c4d.ID_USERDATA,1]  
                
                
          #set the sphere to the user given radius      
          obj[c4d.PRIM_SPHERE_RAD] = radiusvalue  
          
          
                
          #convert to a polygonal object  
          newobjList = utils.SendModelingCommand(  
                                  command = c4d.MCOMMAND_CURRENTSTATETOOBJECT,  
                                  list= [obj.GetClone()],  
                                  mode=c4d.MODELINGCOMMANDMODE_ALL,       
                                  doc = doc)  
                                    
          
          #instead of letting the generator creating an object directly  
          #do this set and replace code for your polygonal object  
          if op.GetDown()==None:  
              doc.InsertObject(newobjList[0],op)  
          else:  
              obj_2=op.GetDown()  
              obj_2.Remove()  
              doc.InsertObject(newobjList[0],op)  
                
          return   
          
        

        But I´m not sure if this is the best solution.
        I´m really interested, if there is a better way to solve it.
        There was another post with a circle object lately.

        https://developers.maxon.net/forum/topic/8124/10584_python-generator--spline-outline

        cheers
        Martin

        Edit:
        the geometrical manipaltion of the sphere will be gone after the generator refreshes the sphere.
        It´s just a replacement.
        if you want real procedural geometrie watch out for the Houdini integration.
        or Fabric engine at the beginning of 2015.

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 12/10/2014 at 06:44, xxxxxxxx wrote:

          Great! This is exactly what I was looking for. Thank you so much for taking the time to explain that for me.

          Thanks,
          S

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            On 13/10/2014 at 04:35, xxxxxxxx wrote:

            you´re welcome !
            Cheers,
            Martin

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