Maya for 3D Printing - Rapid Prototyping
In this course we're going to look at something a little different, creating technically accurate 3D printed parts.
# 1 30-12-2007 , 11:19 PM
Registered User
Join Date: Dec 2005
Posts: 84

Link rotating X and Translate X

Hi

I am not sure which subject to post this under because I don’t know if it is going to be a Mel answer or what! I have never used Mel and I think it might be the only way.

I have a scene of a workshop and I have a woodwork vice which the moving parts are made up of two groups, the first group are the parts that move in or out i.e. the front jaw and the two guide bars and the second group is the parts that rotate, i.e. the leading screw, the tommy bar and the bit the tommy bar goes through.

The rotating group I have added to attributes one to control rotate X and one to translate X. I have used the connection editor to join these together and to connect them to the normal rotate X and translate X. The reason I made new attributes and not used the built in ones is I wanted to set minimum and maximum values so the vice can’t go passed closed or open to far.

Then on the non rotating group, I have made a new attribute to control the translate X (again so I can set min and max values).

Then again in the connection editor I have set my new rotate X on the rotating group up to drive the new translate X on the non rotating group.

This starts to work, when I highlight the new rotate X on the rotating group and middle drag as it rotates the vice opens.

The problem is about a quarter turn of the new rotate X and the vice is fully open. What I need to achieve is for every full rotation of the handle the jaw opens about ten units, that would be moves ten units in translate X, and I have not a got a clue how to achieve this.

I know there is an easy manual way of doing it, at frame 1 set a key frame for all the bits that need to move and then so many frames later rotate X one full tern and move the translate X 10 units then set another key frame and so on but I would like to get this to work if I can. Any ideas?

Thanks
Trikeman

# 2 31-12-2007 , 01:05 PM
t1ck135's Avatar
Registered User
Join Date: May 2004
Location: UK
Posts: 1,991
Hi Trikeman,

If I understand correctly then the default behaviour of connecting the rotation with the translation gives far too much of a movement.
If so then the code way to do this would be to start without any connections between the objects and create an expression that is evalutated each frame and results in the rotation. You could then key the rotation in the desired frames.

To do this all you need to do is create an expression that gets the rotation of object 1, dilutes it to a much smaller amount and then apply it to the translation of object two.
Open up the expression editor and create a new expression using the following code:
Code:
$pObjValue = `getAttr "pCylinder1.rotateX"`;
setAttr pCube1.translateX ($pObjValue / 10);
Line one gets the x axis rotation of the named object
Line two sets the x translation of the named object to be the rotation divided by 10 (which simply dilutes the amount).
To use in your project simply change the names and the division to get the required effect. I would expect if it was a vice then the division would be far higher to give the impression that multiple rotations are needed to move the vice parts a small way.

I've also attached a sample movie showing it working so if need be you can take it apart or modify to suit. I think that if you have an earlier version of maya you will need to open it in notepad and change the version references to yours, e.g, changing 2008 to 7.0 or similar)

Simon

p.s, I split the code up so that it was easier to see but if you wanted a single concise line then the following does the job exactly the same:
Code:
setAttr pCube1.translateX (`getAttr "pCylinder1.rotateX"` / 10);

Attached Files
File Type: ma test_rotate.ma (62.4 KB, 673 views)

Examples of bTraffic - a traffic animation tool for Maya
bFlocking - a tool for Maya 8.5+ to generate flocking and swarming behaviours
Jan/Feb Challenge 2007 Entry and W.I.P
May/Jun Challenge 2006 Entry and W.I.P
Mar/Apr Challenge 2006 Entry and W.I.P
Jan/Feb Challenge 2006 Entry and W.I.P
Nov/Dec Challenge 2005 Entry and W.I.P
Sep/Oct Challenge 2005 Entry and W.I.P
Jul/Aug Challenge 2005 Entry
www.flash-fx.net

Last edited by t1ck135; 31-12-2007 at 01:11 PM.
# 3 31-12-2007 , 01:10 PM
Registered User
Join Date: Dec 2005
Posts: 84
Hi

Thank you Simon, will get on and give that a try.

Thanks
Trikeman

# 4 31-12-2007 , 01:36 PM
gster123's Avatar
Moderator
Join Date: May 2005
Location: Manchester Uk
Posts: 6,300
Could you just not set up a SDK?

That way you have control over how much movement you have, you could also pre and post infinity the curves


"No pressure, no diamonds" Thomas Carlyle
# 5 31-12-2007 , 02:40 PM
t1ck135's Avatar
Registered User
Join Date: May 2004
Location: UK
Posts: 1,991
I've never done one so dont know steve user added image
will have a look into it though as it sounds good

Simon


Examples of bTraffic - a traffic animation tool for Maya
bFlocking - a tool for Maya 8.5+ to generate flocking and swarming behaviours
Jan/Feb Challenge 2007 Entry and W.I.P
May/Jun Challenge 2006 Entry and W.I.P
Mar/Apr Challenge 2006 Entry and W.I.P
Jan/Feb Challenge 2006 Entry and W.I.P
Nov/Dec Challenge 2005 Entry and W.I.P
Sep/Oct Challenge 2005 Entry and W.I.P
Jul/Aug Challenge 2005 Entry
www.flash-fx.net
Posting Rules Forum Rules
You may not post new threads | You may not post replies | You may not post attachments | You may not edit your posts | BB code is On | Smilies are On | [IMG] code is On | HTML code is Off