Maya Training

Introduction to Hard Surface Modeling

Maya Training

Interiors and Furniture Vol 1 & 2 - Modeling & Cloth

Maya Training

Shading, Lighting and Rendering the Bedroom in MR

Maya Training

Robot volume one - Modeling with animation in mind

Maya Training

Spach-Alspaugh House the complete courseware

Maya Training

Burt The Cartoon Dinosaur Vol 01 - Modeling

New Maya Training

Robot Volume 02 - Hybrid Rigging
You are here > Home > SimplyMaya Community Forums
Loading

Welcome to Simply Maya

Please Sign in or Sign up for an account

Member Login

Lost your password?

Not a member yet? Sign Up!

Old 30-12-2007, 11:19 PM   #1
trikeman
Subscriber
 
Join Date: Dec 2005
Posts: 83
Thanks: 5
Thanked 0 Times in 0 Posts
Default 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
trikeman is offline   Reply With Quote
Old 31-12-2007, 01:05 PM   #2
t1ck135
Registered User
 
t1ck135's Avatar
 
Join Date: May 2004
Location: UK
Posts: 1,991
Thanks: 0
Thanked 0 Times in 0 Posts
Default

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, 67 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.
t1ck135 is offline   Reply With Quote
Old 31-12-2007, 01:10 PM   #3
trikeman
Subscriber
 
Join Date: Dec 2005
Posts: 83
Thanks: 5
Thanked 0 Times in 0 Posts
Default

Hi

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

Thanks
Trikeman
trikeman is offline   Reply With Quote
Old 31-12-2007, 01:36 PM   #4
gster123
Moderator
 
gster123's Avatar
 
Join Date: May 2005
Location: Manchester Uk
Posts: 6,300
Thanks: 1
Thanked 51 Times in 45 Posts
Default

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
gster123 is offline   Reply With Quote
Old 31-12-2007, 02:40 PM   #5
t1ck135
Registered User
 
t1ck135's Avatar
 
Join Date: May 2004
Location: UK
Posts: 1,991
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I've never done one so dont know steve
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
t1ck135 is offline   Reply With Quote

A little bit about who we are
Links you might find useful
Catch up with SimplyMaya
SimplyMaya specialises in Maya tutorials. We offer over 1,000 individual Maya training videos, ranging from basic Maya tutorials through to intermediate Maya tutorials. Our tutorials are created by instructors with industry experience and are designed to get you up and running in Maya quickly without making it seem like hard work.

Copyright © 1999-2015 SimplyMaya - vBulletin® Copyright © 2000-2015, Jelsoft Enterprises Ltd.