Forum Groups
  All forums
    Help & Feedback
      Work in progress
      Finished Art
      Non-Max related

Maxunderground news unavailable

Maxscript for loading/merging files
show user profile  jpedleham
Hi, Im trying to figure out how to script a button that will grab the current file location, load another file then merge in the first file then group the merged geometry and align it to a certain object in the scene. I Havent been able to find any extensive documentation on maxscript which makes me think im looking in the wrong places. if anyone could help me out with code snippets or direct me to somewhere that i can find some snippets id be really grateful!
read 1794 times
11/16/2014 3:47:13 PM (last edit: 11/16/2014 3:47:13 PM)
show user profile  reeves1984
Here is a not-very-extensive list on my blog

Get the scene name:

/* Scene Path (read only)*/
FilePath = maxFilePath
/* Scene Filename (read only) */
FileName = maxFileName

It wasn't hard to find commands for merging scenes...

You can select the merged objects, so you could group them etc.

Simon Reeves - VFX Artist & Blog
twitter <-- I work here

read 1764 times
11/17/2014 12:04:35 PM (last edit: 11/17/2014 12:04:35 PM)
show user profile  jpedleham
Thanks man, i cant have been using the right keywords in the help files. its not exactly user friendly!
P.S. I Use your render calculator all the time!
read 1751 times
11/17/2014 10:59:18 PM (last edit: 11/17/2014 10:59:18 PM)
show user profile  jpedleham
So ive managed to get the first half of the script working with

max file save
p = maxfilepath
n = maxfilename
print n
loadmaxfile("[FILE PATH]")
mergemaxfile(p + n)

but i cant find a command to select the merged geometry once its merged.
I havent began looking for the align commands.

One other problem im having is that i want to group the entire scene before i save it out

im using

max select none
select $*
group selection

But it returns a selection empty error. however if i execute the code

max select none
select $*

and then type

group selection

it works fine. any ideas?

read 1750 times
11/17/2014 11:16:37 PM (last edit: 11/18/2014 12:12:46 AM)
show user profile  Garp
> but i cant find a command to select the merged geometry once its merged

Store the geo in an array before merging. After merging, select the geo not in the array.

old_geo = geometry as array
-- merge stuff
select (for x in geometry where (findItem old_geo x) == 0 collect x)

read 1747 times
11/18/2014 3:23:15 AM (last edit: 11/18/2014 3:50:32 PM)
show user profile  jpedleham
I cant seem to get that code to work it says oldgeo is undeclared :/

Im thinking i could merge the objects into the scene and select everything then deselect the objects i dont want grouped. Ive tried the code but again it seems the select function needs a moment to sleect the geometry otherwise it doesnt select anything. is there a 'wait until previous command has finished' type function in max?
It works if i manually type each line into the listener but as a script it seems like it executes too quickly for the code to function properly?
read 1715 times
11/18/2014 4:39:29 PM (last edit: 11/18/2014 4:41:40 PM)
show user profile  Garp
It works fine on my end.
Are you sure that by the time you call select, old_geo is still in scope?
And you didn't make a typo, like old_geo and oldgeo, did you?

read 1708 times
11/18/2014 5:36:30 PM (last edit: 11/18/2014 5:38:32 PM)
show user profile  jpedleham
I dont think i did i copied and pasted it direct.
Ill try putting the oldgeo as the first line and get back to you.

read 1704 times
11/18/2014 5:41:34 PM (last edit: 11/18/2014 5:41:34 PM)
#Maxforums IRC
Open chat window