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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Problems with c4d.utils.Neighbor

    Scheduled Pinned Locked Moved PYTHON Development
    4 Posts 0 Posters 363 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/02/2013 at 08:57, xxxxxxxx wrote:

      Hi everyone,

      I want to convert an edge to a point selection and then get the corresponding neighboring polys.
      If I want to use the neighbor class it doesn't seem to work properly. If I try to initialize it the following way

          obj = doc.GetActiveObject()
          nb = c4d.utils.Neighbor
          nb.Init(obj,None)
          poly_a, poly_b = nb.GetEdgePolys(point_a,point_b)
      

      the console says:

      TypeError: descriptor 'Init' requires a 'c4d.utils.Neighbor' object but received a 'c4d.PolygonObject'
      

      Though the SDK clearly states that Init requires a PolygonObject and optionally a BaseSelect.

      What am I doing wrong here? Might be a stupid question, but I didn't use python for a long time in Cinema and the SDK always gives me headaches...

      Kind Regards

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

        On 08/02/2013 at 08:59, xxxxxxxx wrote:

        You did not instantiate the Neighbor class. You just assigned the class itself to a new variable.

        nb = c4d.utils.Neighbor()
        

        The reason for the error message is, that you can call the Init() function the procedural way, too:

        nb = c4d.utils.Neighbor()
          
        nb.Init(obj, None)
        # same as
        c4d.utils.Neighbor.Init(nb, obj, None)
        
        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          On 08/02/2013 at 10:50, xxxxxxxx wrote:

          you can also compute the indices for yourself.

          subindex = edge_index%4
          cpoly = obj.GetPolygon((edge_index - subindex )/4)
            
          if subindex  == 0:
          	a, b = cpoly.a, cpoly.b
          if subindex  == 1:
          	a, b = cpoly.b, cpoly.c
          if subindex  == 2:
          	a, b = cpoly.c, cpoly.d
          if subindex  == 3:
          	a, b = cpoly.d, cpoly.a
          

          you will have to do half the work with the neighbour class anyway 🙂

          edit: assuming that cpoly.c != cpoly.d, if not 2 is a,b = cpoly.c, cpoly.a

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

            On 09/02/2013 at 04:34, xxxxxxxx wrote:

            Works fine now. Thank you.🙂 The small mistakes...😲

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