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

    Adding points to point selection tag in python

    Scheduled Pinned Locked Moved PYTHON Development
    4 Posts 0 Posters 360 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 08/11/2015 at 05:44, xxxxxxxx wrote:

      Hi everyone,
      I'm a beginner at python (scripting) trying to make a script which would create polygons and let the user adjust certain points.
      So my solution is pre-set a points selection tag then setup a user data interface and connect it in xpresso.
      I have the code below and it create and insert point selection tag to the object but the tag is empty.
      Could anyone one tell me why please?

      import c4d
      from c4d import documents
      def main() :
          doc = documents.GetActiveDocument()
          myPolygon = c4d.BaseObject(c4d.Opolygon)
          myPolygon.ResizeObject(4,1) #New number of points, New number of polygons
          myPolygon.SetPoint(0,c4d.Vector(14.202,475.695,0))
          myPolygon.SetPoint(1,c4d.Vector(2.503,378.908,-42.934))
          myPolygon.SetPoint(2,c4d.Vector(-250.225,-255.247,-42.934))
          myPolygon.SetPoint(3,c4d.Vector(-288.184,-239.534,0))
          myPolygon.SetPolygon(0, c4d.CPolygon(0,1,2,3))
          pointTag= c4d.BaseTag(5674) 
          doc.SetSelection(pointTag, mode=c4d.SELECTION_ADD)
          PointList=[1,2,3]
          for i in PointList:
              myPolygon.GetPointS().Select(i)
          myPolygon.InsertTag(pointTag)
          doc.InsertObject(myPolygon)
          c4d.EventAdd()

      if __name__=='__main__':
          main()

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

        On 08/11/2015 at 06:53, xxxxxxxx wrote:

        You never add any points to the selection tag. You select points on the object itself, but that doesn't fill a selection tag with data.

        doc.SetSelection() deals with objects, not points. (I'm actually not sure what happens in your case because the pointTag is not in the document at the execution time at all...)

        Use GetBaseSelect() on your tag to retrieve a BaseSelect which you can then fill with your selected points.

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

          On 09/11/2015 at 01:54, xxxxxxxx wrote:

          Hello,

          as Cairyn already stated, you don't edit the Point Selection Tag but the point selection of the polygon object. To access the BaseSelect object storing the selection of the tag use GetBaseSelect().

          You find a related topic with example code how to handle selections here:

          • Select polygons from Selection Tag

          Also, please do not cross post on different online boards or at least include links to already existing threads on the topic.

          Best wishes,
          Sebastian

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

            On 20/11/2015 at 09:12, xxxxxxxx wrote:

            Hello online,

            was your question answered?

            Best wishes,
            Sebastian

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