xyz location

xyz location

Anonymous
Not applicable
676 Views
4 Replies
Message 1 of 5

xyz location

Anonymous
Not applicable

I'm creating my own ui window in python and I'd like xyz location to be shown/edited/updated like in the modeling toolkit. I've tried a float field that prints world space but I can't quite get it right. Been trying at this for days! Any help would be appreciated. 

0 Likes
Accepted solutions (1)
677 Views
4 Replies
Replies (4)
Message 2 of 5

jmreinhart
Advisor
Advisor
Accepted solution

I'm not certain if this is the type of thing you are looking for, but what you're describing sounds like this:

https://download.autodesk.com/us/maya/2010help/CommandsPython/show.html?attrFieldGrp.html&cat=Window...

 

If you want it to update when your selection changes I think you'll need to use callbacks. But I don't know much about them.

0 Likes
Message 3 of 5

Anonymous
Not applicable

Thank you for the reply. I did discover attrFieldGrp command yesterday and little help from a friend, we did get it working.


window = cmds.window(title='attrFieldGrp Example')
selection = cmds.ls(sl=True)
cmds.columnLayout()
if selection != None and len(selection)> 0:
    cmds.attrFieldGrp( attribute='%s.translate' % selection[0] )
cmds.showWindow()

 

Like you said, I need to figure out how to make it update when a new selection is made. 
Couple of more issues I have. Keep the world space info even if it gets freezetransformed, currently it goes to 0,0,0.

 I'd like more number of fields but looks like this command is capped at 3. 

0 Likes
Message 4 of 5

Anonymous
Not applicable

Just figured out the number of fields!
precision

0 Likes
Message 5 of 5

jmreinhart
Advisor
Advisor

Unfortunately there is not a single attribute that will give you the worldSpace pivot position that is immune to "freezeTransforms", so if you want to use the attrFieldGrp you will need to add an attribute and calculate the worldspace pivot position and plug it into that attribute (since it seems like you want this to work on all nodes that's not a reasonable option). If you don't have experience with the Maya API then you could use a scriptjob to trigger a script when the selection changes and have that script update the value of floatFields in your UI. I know you can set a scriptjob to be triggered by a selection change but I don't think you can have it triggered when the translate manipulator is used, but I may be mistaken.

0 Likes