How to join non-insert objects?



  • 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



  • 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()  
      
    


  • 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


Log in to reply