Community
Maya Programming
Welcome to Autodeskโ€™s Maya Forums. Share your knowledge, ask questions, and explore popular Maya SDK topics.
cancel
Showing results forย 
Showย ย onlyย  | Search instead forย 
Did you mean:ย 

Object Parenting Problem

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
danispag
806 Views, 3 Replies

Object Parenting Problem

I have a list of Groups with a curve as a child object. I want to parent the group to the cild (curve) of the previous group. Images attached as an example. How do I do it wit python?

Thanks in advance ๐Ÿ™‚

Labels (1)
3 REPLIES 3
Message 2 of 4
jarombrand
in reply to: danispag

There are several ways you could do it, but here is one way with PyMel:

import pymel.core as pm

sel = pm.selected()

for x, s in enumerate(sel):
    if x:
        pm.parent(s, sel[x-1].getChildren())

 

Simply selected the groups in the order you want them parented and run this code. Let me know if you have questions about it

Message 3 of 4
danielblaze
in reply to: jarombrand

I'm getting this error:

 

# Error: line 1: MayaAttributeError: file /Applications/Autodesk/maya2017/Maya.app/Contents/Frameworks/Python.framework/Versions/Current/lib/python2.7/site-packages/pymel/core/general.py line 2200: Maya Attribute does not exist (or is not unique):: u"[nt.Transform(u'nurbsCircle2')]" #

Message 4 of 4
jarombrand
in reply to: danielblaze

Because Maya is dependent on node names, if there are duplicate node names in the scene it can screw things up. I would suggest properly naming your nodes before using this script. 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report