displayed the points equally



  • On 23/08/2014 at 18:17, xxxxxxxx wrote:

    hi everyone 
    I begin to study, and python is still two months

    I made a script for the first time

    I made the script which displayed the points equally

    In fact, only the point that you chose wants to make a script to display equally, do you know it?

    Thank you for keeping company at poor English

    import c4d

    def PointModify(obj) :
        pts = obj.GetAllPoints()
        lisx = []
        for c1 in xrange(op.GetPointCount()) :
            lisx.append(obj.GetPoint(c1).x)
        mx = max(lisx) #find max x position
        nx = min(lisx) #find mini x position
        bunbo = len(lisx) 
        for c in xrange(op.GetPointCount()) :
            pts[c].x = ((bunbo -1 - c)*nx + c*mx)/(bunbo-1) #internally divide
        obj.SetAllPoints(pts)
        obj[c4d.SPLINEOBJECT_TYPE] = c4d.SPLINEOBJECT_TYPE_LINEAR
        obj.Message(c4d.MSG_UPDATE)

    if __name__=='__main__':
        PointModify(op)
        c4d.EventAdd()



  • On 27/08/2014 at 13:04, xxxxxxxx wrote:

    Hello,

    I'm not quite sure what you want to achieve. I guess you are writing a script for the script manager?

    So first you need to get the spline object you want to edit. In the script manager you can get this from the BaseDocument. Then you should check if this is really a spline object; do this by checking the type.

    if __name__=='__main__':  
      splineObject = doc.GetActiveObject()  
        
      if splineObject.GetType() == c4d.Ospline:  
          PointModify(splineObject)  
          c4d.EventAdd()
    

    To limit your operations to the selected points of a spline you can get the selection:

    selectedPoints = splineObject.GetPointS()
    

    The interpolation can only be defined for the whole spline object. If you want to add some linear passages you could edit the tangents of the points.

    best wishes,
    Sebastian



  • On 22/09/2014 at 16:18, xxxxxxxx wrote:

    thankyou for answer polite
    i was very helpful


Log in to reply