Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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

    Rotate selected polygons

    Cinema 4D SDK
    r20 python windows
    2
    3
    790
    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.
    • P
      pim
      last edited by pim

      How can I rotate just the selected polygons (or points) of an object?

      Edit:
      I solved it for points, so polygons should be possible too.

      import c4d
      from c4d import gui
      
      def rot_points(obj, new_axis):
        mat = ~new_axis * obj.GetMl()
        if obj.CheckType(c4d.Opoint):
      
          points = obj.GetAllPoints()
          bs = op.GetPointS()
          sel = bs.GetAll(op.GetPointCount())
          for index, selected in enumerate(sel):
            if not selected: 
              pass
            else:
              points[index] = points[index] * mat
            
          obj.SetAllPoints(points)
          obj.Message(c4d.MSG_UPDATE)
      
        return
        
      # Main function
      def main()
          mat = op.GetMl() * c4d.utils.MatrixRotX(c4d.utils.Rad(45))
          rot_points(op, mat)
          c4d.EventAdd()    
      
      # Execute main()
      if __name__=='__main__':
          main()
      
      1 Reply Last reply Reply Quote 0
      • a_blockA
        a_block
        last edited by

        Hi Pim,

        although you marked this already as solved, I'd just like to clarify one point.
        There is no such thing as rotating polygons. Polygons are just made up of points (or rather point indexes), with the edges being implicitly defined by the order of points in a CPolygon. So rotating a polygon boils down to rotating the points involved in this polygon.

        Cheers,
        Andreas

        1 Reply Last reply Reply Quote 1
        • P
          pim
          last edited by

          Hi Andreas,

          Ok, so I have to rotate the points to rotate a polygon.
          I thought so. That is why I assumed that when I can rotate points, I can rotate polygons.
          Thanks.

          Regards, Pim

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