Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

setAttr heightBaseline?

setAttr heightBaseline?

klawchi
Enthusiast Enthusiast
304 Views
2 Replies
Message 1 of 3

setAttr heightBaseline?

klawchi
Enthusiast
Enthusiast

I am trying to change the heightBaseline of a selcted object but can't get any solutions 😞

 

import maya.cmds as cmds
selected = cmds.ls(sl=True)[0]
cmds.setAttr(selected.heightBaseline, -1)

 

I tried to query the baseline with:

baseline = cmds.getAttr('{0}.heightBaseline'.format(selected))

 

But no luck

 

Any help will be appreciated

0 Likes
Accepted solutions (2)
305 Views
2 Replies
Replies (2)
Message 2 of 3

FirespriteNate
Advocate
Advocate
Accepted solution

you have to wrap literal strings in "quotes". If you want to "join" them to object names, you have to concatenate them. There are different (and better) ways to do this in Python, but the simplest way is like so:

 

 

import maya.cmds as cmds
selected = cmds.ls(sl=True)[0]
cmds.setAttr(selected+".heightBaseline", -1)

 

However, this is not your issue. The issue is that .heightBaseLine is an attribute of the history of an object, and what you have selected is likely the transform. You either have to select the history node, and the code snippet will work, or you have to find the history node from the selected transform/mesh. 

Something like:

selected = cmds.ls(sl=True)[0]
hist = cmds.listHistory(selected, pruneDagObjects=True)[0]
cmds.setAttr(hist+'.heightBaseLine', -1)

(but this becomes more complex if you have objects with more than one history state).

Message 3 of 3

klawchi
Enthusiast
Enthusiast
Accepted solution

Yes, this is fixed the issue.

Thank you for explaining it in details.

0 Likes