Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # import the cinema 4d module
- import c4d
- def main():
- # get the selected object in the document
- # note: this works only in the script manager !
- # otherwise use doc.GetActiveObject()
- cloner = op
- # check if there is a selected object,
- # and if so, if it is a cloner.
- # note: The ID of a cloner object is not within
- # the c4d-module. I obtained it using
- # c4d.BaseObject.GetType()
- if not op \
- or not op.CheckType(1018544):
- print "No object selected, or the selected " \
- "one is not a cloner-object."
- # exit the function
- return
- # get the cache of the selected object
- cache = cloner.GetCache()
- # now check if the cache was built, if it
- # was not, cache equals `None`
- if not cache:
- print "The cache of the cloner has not been " \
- "built yet."
- # exit the function
- return
- # the cache of a cloner object is a Null-object.
- # its children are the actual clones of the cloner
- # we obtain them all in a list using the convenient
- # function: c4d.BaseObject.GetChildren()
- clones = cache.GetChildren()
- # we will now iterator over all clones.
- # the enumerate function enables us to
- # iterate not only over the clones, but
- # also over their index in the list
- # (thanks to Pythons unpacking-syntax)
- for index, clone in enumerate(clones):
- # the clone should be placed at
- # the position of `index` * 50 in all
- # three components
- pos = c4d.Vector(index * 50)
- clone.SetAbsPos(pos)
- # notify the cloner that something was
- # changed
- cloner.Message(c4d.MSG_UPDATE)
- # notify cinema 4d to update the editor
- c4d.EventAdd()
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement