PDA

View Full Version : Transform script, local coords


mbst
06-19-2003, 06:03 PM
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 :)

LFShade
06-19-2003, 07:44 PM
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

mbst
06-19-2003, 09:31 PM
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..

:)

LFShade
06-20-2003, 12:57 AM
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

Bobo
06-20-2003, 08:25 PM
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.

mbst
06-20-2003, 10:03 PM
Ok, I'll check it out. Thanks! :)

CGTalk Moderation
01-15-2006, 11:00 AM
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.