Jump to content
3DCoat Forums

changing parent with Python: nothing happens?


kritskiy.001
 Share

Go to solution Solved by Andrew Shpagin,

Recommended Posts

  • Member

First of all, it's awesome to see Python implementation in 3d Coat — it's so, so so much easier to dive into for mere mortals than AS and C.

I'm struggling with something: I'm trying to change parent for selected volumes from Root to an object with index 0 and while the console prints out correct values nothing happens in the scene: the parents don't change. My scene consists of 4 simple sphere volumes, two bottom ones are selected (selecting one doesn't make difference)

Code:

import coat

def main():
	root = coat.Scene.sculptRoot()
	new_parent = root.child(index = 0)
	selected = []

	def walker(el):
		if el.selected():
			selected.append(el)

	root.iterateVisibleSubtree(walker)
	print(f"selected elements: {selected}") # correctly outputs coat.SceneElement objects

	for el in selected:
		print(f"changing parent: {el.name()} from {el.parent().name()} to {new_parent.name()}") # prints out correct names
		el.changeParent(newParent = new_parent) # nothing happens
			
main()

Please let me know what am I missing.

Thanks!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...