MaxScript

This post comes from my need to learn MaxScript in a pretty short amount of time. I am a long time user of both Mel and Python and so I don’t see it as being impossible to learn quickly.

What I am running into is an inability to grasp how Max accomplishes a lot of tasks. Even using something like the Macro recorder doesn’t yield all the information I need to know what Max is doing.

My example is in using a constraint. I want to script a position constraint. The first thing I do is actually create one to see what commands are thrown when the position constraint is used.

macros.run “Constraints” “Position_Constraint”

It returns this and then I select the 2 boxes and it snaps them together. The problem is I don’t what to use the interface tool to do it. I want my script to constrain two specified objects. Now i look for the command in the help docs.

constructor
Position_Constraint…

That is all the info I get. No flags or place to put the names of the objects I want to position constraint.

so That lengthy post is just to ask. Is there something I need to do to help me grasp how MaxScript works? How do I go about finding the information I need?

Forget about using the macro recorder to learn maxscript.
It is not a good tool for that.

Try the maxscript help. It has many tutorials from beginner to advanced.

And also:

The above page gives you a head start (thanks to Bobo).

I second the max script help, that got me up and running in a week after moving over from Mel.

MSN is your friend. Find someone that knows MXS well and bug them (I’ll volunteer).

Also, keep on posting in here - everyone here’s helpful! I’m far from an expert, but I can certainly help with some things.

Also, the max help is a great reference, but the samples are what I’d recommend stepping through - there are a handful of great tutorials in there, and many of the commands have an “Example” section – such as the Position_Constraint!

rob if you’re seriously offering, i’m going to jump all over that. virtually no one at my studio has any maxscript experience, so as another maya convert, i very much sympathize with bharris’ plight.

my biggest problem with maxscript has been finding the right terminology to search for. i know vaguely what i want to search for, but finding the right search term is half the battle (example: trying to find mesh methods… why are these commands erroring out… oh wait this is editable poly, completely different set of methods. there goes an hour)

also i found the cg academy maxscript dvd’s to be helpful in the initial conversion. the examples are very basic but the workflow is what helped me most. being able to see the classOf commands in use, for example, has saved me work down the line and allowed me to better approach and troubleshoot issues.

[QUOTE=jeremyc;2944]rob if you’re seriously offering, i’m going to jump all over that. virtually no one at my studio has any maxscript experience, so as another maya convert, i very much sympathize with bharris’ plight.[/quote]
Something I was thinking about setting up yesterday is a TAO IRC room for this sort of thing. I will work on getting it set up this weekend, it can make a really good language learning resource. But for now, yes I’m offering to answer your questions.

my biggest problem with maxscript has been finding the right terminology to search for. i know vaguely what i want to search for, but finding the right search term is half the battle (example: trying to find mesh methods… why are these commands erroring out… oh wait this is editable poly, completely different set of methods. there goes an hour)

Yup, the help file is excellent, navigating the language itself is difficult. Once you get behind the logic, it becomes much better. The documentation is excellent, blame the shitty language.

well hell, that sounds like a deal.

I figured out the position constraint and will post what the main problems occurred.

Maya point constraint

example:
string $bhConstraint = pointConstraint -maintainOffset 0 "target" "object;

now in maxScript the code isn’t that simple and I’m still trying to figure out exactly what is happening. so to start we create a constraint.

–This creates a constraint instance? I assign it to a variable to access it
–later
pc = Position_Constraint()

–Now I must tell the object I want to be effecting that the constraint is now --driving its position
$box01.pos.controller = pc

–Now I’m accessing the constraints interface
positionConstraintInterface = pc.constraints

–Here is where I add a control object to the constraint and tell it how heavy --its weight is
positionConstraintInterface.appendtarget $Box02 100

so the main hurdle is being understanding that everything is its own object and that I must access objects instead of object nodes with attributes?

$Box01.pos.controller = Position_Constraint()
$Box01.pos.controller.appendTarget $Box2 100

Max is semi-object oriented, so you have to think about it in terms of objects. Except when it doesn’t work OO like it should, then you think about suicide.

You’ll learn to LIKE using MXS but HATE scripting in Max, but LIKE scripting in Maya but HATE using MEL. At least that’s what I’ve found from talking to others.

well after switching to python, I definitely don’t have as much fun scripting in mel, but it still feels natural to use. maxScript right now feels like walking on my elbows. I’ll master it eventually.

Regarding the point constraint, I highly suggest reading through the pages in the MaxScript help file titled “Node Transform Properties” and “Using Node Transform Properties”

It explains how a transform for an object is generated - and also sheds a lot of light on how you have to control them.

In a nutshell, a node by itself is just a node with a transform. Max uses objects called “Controllers” to determine a node’s position, rotation, and scale – and different constraints are usually either replacing or overriding certain parts of a controlled.

The basic controlled is the PRS controller - for Position, Rotation, and Scale.

Rather than creating a “constraint” like in Maya, you use a “Position_Constraint” as the Position controller. This will also show up in the Track View, and other places. Some controllers, like the Path Controller, will modify the node’s Position and also add in some rotation of their own – so you should always read the docs the first time you use them – they can add little side effects that seem weird until you read what’s going on under the hood.

The “Node Common Properties” page is also enlightening - definitely good grounding material.

~Alex

good call. thanks for the advice. Ill be putting it to good use

The Maxscript help is a great source of information, as is downloading and reading other peoples scripts that are doing something similar to what you want to achive. - like from http://www.scriptspot.com

The thing that is bad is trying to find what you are looking for in the Maxscript help, I’ve seen this mentioned twice on here in the last few days and it always annoys me!!

Maybe there is some mileage in overhalling the CHM files in someway to make them better to navigate!

its funny I find the max help for maxscript great because most of the time if I highlight a command in the script and hit f1 it will load help to that page /search term. And the cross links at the bottom of the help files along with the samples are great compared to searching the maya mel doc… (but I like it is one big list vs max).

The hardest part of maxscript is figuring out what it is that max calls a tool behind the scenes. That just took looking over scriptspot scripts and listener watching and guessing.

I am in agreement there. Plus max is structured very differently from Maya. It may be that I have been using Maya for years, but it still felt a lot more natural to pick up.

I hope you have been able to see a good post! Come on! Support youSKF轴承型号SKF轴承型号SKF轴承型号