Skip to content

Instantly share code, notes, and snippets.

@MikeUdin
Created October 11, 2016 14:54
Show Gist options
  • Save MikeUdin/45cf7c812b1cfe814229826d0ac9f0e9 to your computer and use it in GitHub Desktop.
Save MikeUdin/45cf7c812b1cfe814229826d0ac9f0e9 to your computer and use it in GitHub Desktop.
Place selected objects as childs to Parent from popup menu
import c4d
from c4d import gui
# Welcome to the world of Python
# Author: Mike Udin,
# Tutorial here http://mikeudin.net/?p=2930
# 2016
def main():
objs = doc.GetActiveObjects(1)
if not objs: return
tlist = [1018791, 1018544, 1010865, 5142, 1011010, 1019396, 5140]
menu = c4d.BaseContainer()
for otype in tlist:
menu.SetString(c4d.FIRST_POPUP_ID+len(menu), c4d.GetObjectName(otype))
result = gui.ShowPopupDialog(cd=None, bc=menu, x=c4d.MOUSEPOS, y=c4d.MOUSEPOS)-c4d.FIRST_POPUP_ID
if result<0:return
parent = c4d.BaseObject(tlist[result])
parent.InsertBefore(objs[0])
parent.SetBit(c4d.BIT_ACTIVE)
for obj in reversed(objs):
obj.InsertUnder(parent)
obj.DelBit(c4d.BIT_ACTIVE)
c4d.EventAdd()
if __name__=='__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment