Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import c4d
- from c4d.gui import MessageDialog
- def main():
- if not op:
- # op is None, no selected object or multiple ones
- MessageDialog("You must select exactly one object.")
- return
- if not isinstance(op, c4d.PointObject):
- # selected object is not a PointObject, we cannot center the axis
- MessageDialog("You must select either a spline or polygon object")
- return
- points = op.GetAllPoints()
- min = c4d.Vector()
- max = c4d.Vector()
- op_position = op.GetAbsPos()
- for p in points:
- p = p + op_position
- if p.x < min.x:
- min.x = p.x
- if p.x > max.x:
- max.x = p.x
- if p.y < min.y:
- min.y = p.y
- if p.y > max.y:
- max.y = p.y
- if p.z < min.z:
- min.z = p.z
- if p.z > max.z:
- max.z = p.z
- center = (min + max) / 2.
- print min, max, center
- # ...
- for index, p in enumerate(points):
- p = p - center
- points[index] = p
- op.SetAllPoints(points)
- """
- op.SetAbsPos(op_position - center)"""
- op.Message(c4d.MSG_UPDATE)
- c4d.EventAdd()
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement