Advertisement
nux95

Untitled

Nov 26th, 2011
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.79 KB | None | 0 0
  1. # import the cinema 4d module
  2. import c4d
  3.  
  4. def main():
  5.     # get the selected object in the document
  6.     # note: this works only in the script manager !
  7.     #       otherwise use doc.GetActiveObject()
  8.     cloner = op
  9.  
  10.     # check if there is a selected object,
  11.     # and if so, if it is a cloner.
  12.     # note: The ID of a cloner object is not within
  13.     #       the c4d-module. I obtained it using
  14.     #       c4d.BaseObject.GetType()
  15.     if not op \
  16.     or not op.CheckType(1018544):
  17.         print "No object selected, or the selected " \
  18.               "one is not a cloner-object."
  19.         # exit the function
  20.         return
  21.  
  22.     # get the cache of the selected object
  23.     cache  = cloner.GetCache()
  24.  
  25.     # now check if the cache was built, if it
  26.     # was not, cache equals `None`
  27.     if not cache:
  28.         print "The cache of the cloner has not been " \
  29.               "built yet."
  30.         # exit the function
  31.         return
  32.  
  33.     # the cache of a cloner object is a Null-object.
  34.     # its children are the actual clones of the cloner
  35.     # we obtain them all in a list using the convenient
  36.     # function: c4d.BaseObject.GetChildren()
  37.     clones = cache.GetChildren()
  38.  
  39.     # we will now iterator over all clones.
  40.     # the enumerate function enables us to
  41.     # iterate not only over the clones, but
  42.     # also over their index in the list
  43.     # (thanks to Pythons unpacking-syntax)
  44.     for index, clone in enumerate(clones):
  45.         # the clone should be placed at
  46.         # the position of `index` * 50 in all
  47.         # three components
  48.         pos = c4d.Vector(index * 50)
  49.         clone.SetAbsPos(pos)
  50.  
  51.     # notify the cloner that something was
  52.     # changed
  53.     cloner.Message(c4d.MSG_UPDATE)
  54.  
  55.     # notify cinema 4d to update the editor
  56.     c4d.EventAdd()
  57.  
  58. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement