Message 1 of 3

Not applicable
12-16-2019
02:16 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I want to unparent an object (and make it a child of the world), do some things, and then reparent it to its original parent transform.
Here's what I'm trying:
import maya.cmds as cmds sel = cmds.ls(selection=True)[0] initialParent = cmds.listRelatives(sel, parent=1)[0] cmds.parent(sel, world=True) #Do stuff cmds.parent(sel, initialParent)
The hierarchy is
group1
> cube1 (selected when running script)
The error says: 'No object matches name: group1|cube1
It must be my fundamental misunderstanding of how python works - I'm assuming initialParent is getting changed when cube1 is unparented? And therefore it no longer works? I'm a bit baffled.
Any help much appreciated!
Solved! Go to Solution.