Transform script, local coords

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  06 June 2003
Question Transform script, local coords

Hi, I'd like some help writing a small script to Max 5 which I will use to automate some transforms on a bunch of objects.
I've never used MaxScript before, but am familiar with basic java programming.


What I want it to do is perform the following actions on the currently selected object, using it's local coordinate system as coord.system:

Relative rotation: (x y z)=(90 0 0)
Relative move: (x y z)=(0 0 4)


Also, is it possible to execute scripts with keyboard shortcuts?


I've looked in the MaxScript reference file, but failed to find what I needed.

Thanks in advance,
Martin
 
  06 June 2003
Welcome to MAXScript!

Try this:

for obj in selection do
(
in coordsys obj
(
rotate obj (eulerAngles 90 0 0)
move obj [0,0,4]
)
)


The only thing to consider here is that you should always do the rotation first, then the position. And since the rotation changes the orientation of the object's local axes, the position is changed based on the new orientation. If you want to perform the translation based on the original (pre-rotation) orientation of the axes, you could do this:

for obj in selection do
(
in coordsys obj
(
move obj [0,0,4]
obj_pos = obj.pos
rotate obj (eulerAngles 90 0 0)
obj.pos = obj_pos
)
)


What this does is move the object first, then store the position and restore it again after the rotation. In any case, though, it's important to follow rotation with translation when working directly with object transforms.

Make any sense?


RH
__________________
Got Maxscript?
RHTools
 
  06 June 2003
Quote: Originally posted by LFShade
Make any sense?

Yes, thank you very much for the good explanation.

By the way, I really like the tone of this forum. You're all almost too helpful..

 
  06 June 2003
Quote: You're all almost too helpful..

Well, I'll try to be a little less helpful next time then

But seriously...I completely glossed over your question about executing scripts from the keyboard and such. The thing you'll want to look up in the docs is called a macroScript. You basically just wrap the code in a macroScript definition, and then you can assign it to buttons, keyboard shortcuts, quadmenus...whatever. Let us know if you have any trouble figuring it out.

RH
__________________
Got Maxscript?
RHTools
 
  06 June 2003
About keyboard shortcuts:

Back in 3ds max 4, so-called "ActionItems" were introduced. Basically, the complete Keyboard shortcuts system has been rewritten, allowing any item appearing in the Customize dialog to be assigned to a Menu, a QuadMenu, a Toolbar or a Shortcut.

macroScripts (added to Max in R3) also appear in the Customize dialog and can be assigned to toolbars, menus, quads and shortcuts.
You might want to take a look at the "How To" tutorials in the MAXScript Help File for Max 5.x. Many of them demonstrate the definition of MacroScripts.
 
  06 June 2003
Ok, I'll check it out. Thanks!
 
  01 January 2006
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 05:04 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.