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

    displayed the points equally

    Scheduled Pinned Locked Moved PYTHON Development
    3 Posts 0 Posters 235 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 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()

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

        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[URL-REMOVED]. 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[URL-REMOVED]:

        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[URL-REMOVED].

        best wishes,
        Sebastian


        [URL-REMOVED] @maxon: This section contained a non-resolving link which has been removed.

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

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

          thankyou for answer polite
          i was very helpful

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