Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 09/16/2018 in all areas

  1. ...never to late with this code examples, good job mate (and small description of every line/blok would be amazing. This kind of scripts could be very simply "readable" for non-coder users to understand what those lines of code means. Directly from this script how to handle with multiple selected objects instead of single one and perform some "actions" with them...) Thanks...
    1 point
  2. a bit late but anyway :) import c4d from c4d import gui #Welcome to the world of Python def main(): doc.StartUndo() # this generates an UNDO stack, every "AddUndo" between .StartUndo() and .EndUndo() will be "undoable" in a single "Ctrl+Z" objects = doc.GetActiveObjects(0) # this get's currently active objects in a list. The "0" parameter means that we don't want to select the children of the objects and we don't care about the oreder of the returned selection for obj in objects: # this iterates over the list of active objects. So for each object: instance = c4d.BaseObject(c4d.Oinstance) # create a new instance object instance.SetName(obj.GetName() + '_instance') # set it's name to the object's name + "_instance" instance[c4d.INSTANCEOBJECT_LINK] = obj # set the instance's source object instance.InsertBefore(obj) # insert the instance object in the object manager, right before the source object. You can use other options. Like .InsertAfter(obj), if you want it after the source object. doc.AddUndo(c4d.UNDOTYPE_NEW, instance) # this adds the insertion of our new instance to the undo stack. doc.EndUndo() # this ends the undo stack c4d.EventAdd() # we infrom C4D that something has occured, otherwise it will not refresh until you click something or do something else if __name__=='__main__': main()
    1 point
×
×
  • Create New...