Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save MikeUdin/833dac0c1ec6d9121a6c04934935981f to your computer and use it in GitHub Desktop.
Save MikeUdin/833dac0c1ec6d9121a6c04934935981f to your computer and use it in GitHub Desktop.
import c4d
from c4d import gui
#This script required Cinema 4D R20 and upper
def main():
objs = doc.GetActiveObjects(0)
if not objs:
gui.MessageDialog('Please select some objects!')
return
mcs = []
doc.StartUndo()
for obj in objs:
if obj == objs[0]:
continue
mcs.append(obj.GetMg())
doc.AddUndo(c4d.UNDOTYPE_DELETE,obj)
obj.Remove()
ins = c4d.BaseObject(c4d.Oinstance)
ins[c4d.INSTANCEOBJECT_RENDERINSTANCE_MODE] = 2
ins[c4d.INSTANCEOBJECT_LINK] = objs[0]
ins.SetInstanceMatrices(mcs)
doc.InsertObject(ins)
doc.AddUndo(c4d.UNDOTYPE_NEW,ins)
doc.EndUndo()
c4d.EventAdd()
# Execute main()
if __name__=='__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment