Scale with percentages

Scale with percentages

danispag
Enthusiast Enthusiast
2,136 Views
2 Replies
Message 1 of 3

Scale with percentages

danispag
Enthusiast
Enthusiast

Let’s say I create a 3 joint chain and the distance between the start and end joint has a value of 10 (measured with the distance tool). But if I create another joint chain and the distance has a value of 20, the control should be double the size and so on and so forth.

 

What I want is to replace the “hard coding” with percentages. So if I create a chain with ‘X’ value (distance tool) the control should scale accordingly.

 

Images attached

Thanks in advance

Daniel

0 Likes
Accepted solutions (1)
2,137 Views
2 Replies
Replies (2)
Message 2 of 3

lanh.hong
Alumni
Alumni
Accepted solution

Hi Daniel,

 

You can get the distance from the distance attribute. Then you can set the circle's radius to equal the distance and scale that way. Here's what I came up with based on your sample.

import maya.cmds as cmds

basePos = cmds.xform('joint1', ws=True, t=True, q=True)
endPos = cmds.xform('joint3', ws=True, t=True, q=True)

cmds.distanceDimension(sp = basePos, ep = endPos)

distance = cmds.getAttr('distanceDimension1.distance')
cmds.circle(nr = (0,90,0), c = (0,0,0), r = distance/2)

I hope this helps. 🙂


Lanh Hong
Developer Technical Services
Autodesk Developer Network



Message 3 of 3

danispag
Enthusiast
Enthusiast

That's exactly what i was looking for. Thank you sooooo much :D.

really appreciate

0 Likes