Notifications
Clear all

[Closed] Scene Merge utility

Hopefully someone will be able to help me, there seems to be a lack of content for anyone trying to learn maxscript. Well not a lack of content but content for someone trying to get started… but I digress.

I’m trying to create a simple script ‘utility’ that will merge scene files together when you hit a button. It will be used to load biped figures in to a scene and let people move them around with character studio.

My script so far looks like this:

[I]Utility merger “Merger” width:88 height:40
(
button b1 “Merger Scene” pos:[8,8] width:72 height:24
on unnamedRollout open do
(

)
on unnamedRollout close  do

(

)
on unnamedRollout resized size do

(

)
on unnamedRollout moved pos do

(

)
on b1 pressed  do
	mergeMAXFILE(BIPED.MAX)

)[/I]

Which doesn’t work, bust doesn’t give me any errors in my listener. I’m really flying blind on this, with the maxscript reference as my only guide.

Any help would be greatly appreciated.

3 Replies

Hi DeadlyFreeze,

I’ve corrected your script with changes marked in orange.

For “beginners” info on maxscript I’d recommend you to consult the online help of max (see the “MAXScript for New and Casual users” and other topics). Also, check out the “Examples” directory in the scripts folder…

Utility merger “Merger” width:88 height:40
(
button b1 “Merger Scene” pos:[8,8] width:72 height:24
on merger open do
(

)
on merger close do
(

)

– the ‘on resized’ and ‘on moved’ events only work on dialogs, not on Utilities.

on b1 pressed do
if not (mergeMAXFILE “BIPED.MAX”) then messagebox “File not found!” title:“Merger”
)

mergeMAXFile does not give any errors if the specified file does not exist, instead it returns true on success and false on failure… So the extra line:
if not (mergeMAXFILE “BIPED.MAX”) then messagebox “File not found!” title:“Merger”
shows the messagebox when mergeMAXFile returns false.

In your case, you probably need to prefix the file with the absolute path, something like “D:\Maxfiles\Biped.max”.

If you have any more questions don’t hesitate to post them

cheers.
Martijn

You’ve been a tremendous help, I have one last question and then I should have everything I need. I rewrote the script somewhat, when I run the script I get the menu and can merge the scenes, which is exactly what I want.

I plan on having numerous buttons for each biped and would like to have each group of buttons in its own rollout. When I was looking through the example scripts I found ‘2Example_FloatingWindow.ms’ which use a rollout. I was able to get the buttons in the rollout but I wasn’t able to make multiple rollouts. How would I go about adding this so I can group each set of buttons in the rollout.

With out rollout

utility merger “Merger”
(

button b1 “Merger Scene” pos:[8,8] width:72 height:24
button b2 “Merger Scene2” pos:[100,8] width:72 height:24

on merger open do
(

)
on merger close do
(

)

on b1 pressed do
if not (mergeMAXFILE “D:\3dsmax6\scenes\BIPED1.MAX”) then messagebox “File not found!” title:“Merger”

on b2 pressed do
if not (mergeMAXFILE “D:\3dsmax6\scenes\BIPED2.MAX”) then messagebox “File not found!” title:“Merger”
)
CreateDialog Merger width:400 height:400


With Rollout

rollout scenemerge “Scene Merge” width:88 height:40
(
button b1 “Merger Scene” pos:[200,8] width:72 height:24

on merger open do
(

)
on merger close do
(

)

– the ‘on resized’ and ‘on moved’ events only work on dialogs, not on Utilities.

on b1 pressed do
if not (mergeMAXFILE “D:\3dsmax6\scenes\BIPED.MAX”) then messagebox “File not found!” title:“Merger”

)
– create the rollout window and add the rollout

if FloaterExampleFloater != undefined do
(
closerolloutfloater FloaterExampleFloater
)
FloaterExampleFloater = newRolloutFloater “Scene Merge” 400 400
addRollout FloaterExample FloaterExampleFloater

I hope I dont sound as if im trying to be ‘spoon fed’ the answers. It’s just not clicking in my brain yet.

Here’s a basic example of how to add multiple rollouts to a rolloutfloater

What has helped me a lot in the past (and still!) is the keyword search in the online help. Paste this script in a new script editor, put the caret on the word newRolloutFloater and press F1. This will open the online reference and jumps to the requested topic directly! … (I’m not trying to “RTFM you”, just explaining in case you didn’t know this functionality existed)

rollout scenemerge1 “Scene Merge 1”
(
– rollout controls (buttons etc) go here …
)
rollout scenemerge2 “Scene Merge 2”
(
– rollout controls (buttons etc) go here …
)
rollout scenemerge3 “Scene Merge 3”
(
– rollout controls (buttons etc) go here …
)

if FloaterExampleFloater != undefined do
(
closerolloutfloater FloaterExampleFloater
)
FloaterExampleFloater = newRolloutFloater “Scene Merge” 400 400
addRollout scenemerge1 FloaterExampleFloater
addRollout scenemerge2 FloaterExampleFloater
addRollout scenemerge3 FloaterExampleFloater

  • Martijn