Created
May 26, 2021 11:35
-
-
Save MikeUdin/833dac0c1ec6d9121a6c04934935981f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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