It is quite simple to bring a file dialog to pickup a file outside Max:
filename = getOpenFileName
if filename != undefined then
filename = getSaveFileName
essentially does the same thing but confirm button label is “Save” rather than “Open”.
The file dialog can have more options like:
filename = getSaveFileName \
caption:"Title of the Dialog Window" \
filename:(sysinfo.currentdir + @"\untitled.m")
In Max Script, if you want to create a group, you should have something to be inside the group first. i.e.
So far, I only know how to create an empty Group via Max SDK.
Object *obj = (Object*)CreateInstance(HELPER_CLASS_ID, Class_ID(DUMMY_CLASS_ID,0));
IDerivedObject *dobj = CreateDerivedObject(obj);
child = GetCOREInterface()->CreateObjectNode(dobj);
// attach to another INode*
// attach another INode* to it
Wait a minute. This creates a Dummy, not a Group! A Dummy is quite a different thing. It cannot be closed. It’s bounding box does not respond to stuff under it. If you delete a Dummy, stuff under it will still be there. OK, there is some trick: as long as you type:
It will be a Group! Also there is something I don’t understand: after an API mesh object (say grandChild) is created, I should attach it to an existing Group. Unless I call:
It will fail. I suggest that is due to a mesh object cannot be a group head. Just like only Transform node can have children in Maya. Because I want to put everything in the same hierarchical order as they are in Maya, a mesh cannot have any child should not bother me in this case.
This is a bit of Max Script I have encountered. First how to create a transform node in Max? In Maya, an empty group and a transform node are the same thing. They define the transformation matrix about where to put stuff, and they are not renderable. In Max, I find Dummy, which acts quite like Maya transform. It can be create by Max Script:
or with some initial position:
dummy name:"some_name" pos:[3,4,5]
But Dummy is not just a transformation matrix. It also has a box visualization can be directly picked up in the viewport. In fact, most objects in Max has transformation matrix, even a mesh object can be transformed on its own. Objects can be attached to a Dummy. When you move the Dummy, you move everything under it. So it acts like a Group, but a Dummy is not a Group. They show up differently in scene explorer. I still don’t know how to create an empty Group in Max, with or without Max Script:(
So how to select something by name?
bob = getNodeByName "some_name"
if bob != undefined then
A strange, and maybe amazing, thing about Max is multiple objects in the same place can have the same name. Means there can be two sphere01 under group01, which is not possible in Maya. I am not sure what is the benefit or trouble about this feature. Better to avoid it anyway.