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

    How to join non-insert objects?

    Scheduled Pinned Locked Moved PYTHON Development
    3 Posts 0 Posters 306 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 20/09/2014 at 11:51, xxxxxxxx wrote:

      Hallo everybody,

      subject is the question. But for a better understanding a snippes

      import c4d  
      from c4d import utils  
      #Welcome to the world of Python  
        
      def main() :  
        childs = op.GetChildren()  
        splines = []  
        for child in childs:  
            splines.append(child.GetClone())  
              
        #Here it is doing alot of stuff with the splines  
          
        #After all I want all splines joined to one  
        return spline
      

      Id like to use a command, but Im not sure which one.

      Thx and greetings
      rown

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

        On 20/09/2014 at 12:27, xxxxxxxx wrote:

        hello rown,

        by hand, without a command :
        hope this helps.
        cheers
        Martin

          
        import c4d  
          
          
          
        def main() :  
          matr= op.GetMg()  
          childs = op.GetChildren()  
          splines = []  
          SplinePoints= []  
          for child in childs:  
              splines.append(child.GetClone())  
            
            
          #do stuff with the splines  
            
            
          for sp in splines:  
              Points=sp.GetAllPoints()  
                
              for p in Points:  
                  SplinePoints.append(p)  
          length=len(SplinePoints)  
            
          spline = c4d.SplineObject(2,c4d.SPLINETYPE_BEZIER)   
          doc = c4d.documents.GetActiveDocument()    
          doc.AddUndo(c4d.UNDOTYPE_NEW, spline)  
            
          spline.ResizeObject(length,1)  
          spline.SetSegment(0,length,0)  
          for count in xrange(length) :  
              spline.SetPoint(count,SplinePoints[count])  
          spline.SetMg(matr)  
          spline.Message(c4d.MSG_UPDATE)  
          doc.InsertObject(spline)  
          c4d.EventAdd()  
            
            
        if __name__=='__main__':  
          main()  
          
        
        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 20/09/2014 at 12:48, xxxxxxxx wrote:

          Hello Martin,

          Thx for your lines.
          But it already works 'by hand'.

              pnts = []  
            segs = []  
            for spl in spls:  
                pnts += spl.GetAllPoints()  
                if spl.GetSegmentCount() > 0:  
                    for seg_id in range(spl.GetSegmentCount()) :  
                        segs.append(spl.GetSegment(seg_id)["cnt"])  
                else: segs.append(spl.GetPointCount())  
                  
              
            spline = c4d.BaseObject(c4d.Ospline)  
            spline.ResizeObject(len(pnts),len(segs))  
            for i in range(len(segs)) : spline.SetSegment(i,segs[i], close)  
            spline.SetAllPoints(pnts)  
            spline[c4d.SPLINEOBJECT_CLOSED]=False  
            spline.SetMl(obj.GetMl())  
            spline.Message (c4d.MSG_UPDATE)
          

          I thougth there could be command without running through a number of loops and so on.

          greeting
          rown

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