# Solved Rotate selected polygons

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()
rot_points(op, mat)

# Execute main()
if __name__=='__main__':
main()
``````

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

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