Notifications
Clear all

[Closed] Merging models from numerous scenes?

Hi there MAXScript dudes

I have a problem here that I’m not 100% sure how to solve.

Take a look at my directory of max files first please:

Now, what I need is a script to go through all the “girls_face_modeling_” max files and merge GEOMETRY data only in there, it’d be cool if I could specify which LAYER the geometry is in, that way it’d save me a lot of trouble cleaning up the resulting scene afterwards.

Now, what I don’t know:

  1. how loop through all the max files (the numerics are three place nubers e.g.: 001, 002, 153, 451 etc…) what kind of a numeric value/variable should I use for such numbers?

  2. how to merge geometry only or from a specific layer?

  3. how to re-name the merged models immediately before merging anything else?

cheers in advance gurus, any help will be much appretiated!

3 Replies
  1. how loop through all the max files (the numerics are three place nubers e.g.: 001, 002, 153, 451 etc…) what kind of a numeric value/variable should I use for such numbers?

You could make an array using the getFiles() function then loop thru that array. It would look something like this:

mergedArray = getFiles “c:\your_path_here\*.max”

  1. how to re-name the merged models immediately before merging anything else?

You could use the getMaxFileObjectNames() function on the file you were merging before you merge it, then find the item by its name after the merge and store it in an array. Then you would loop thru that array to rename the files. Something like this:


 
 fn renameMerged objArray = 
 (
 	fooArray = #()
 	mySelection = #()
 	
 	for i in objArray do
 	(
 		name = trimleft i "#"
 		append fooArray name
 	)
 	
 	for i in $objects do
 	(	
 		if ( findItem fooArray i.name != 0 ) then
 		(
 			i.name = "newName"
 			append mySelection i
 		)	
 	)
 	
 	return mySelection
 )
 
 objArray = getMaxFileObjectNames "c:\\your_path_here\\MaxFileName.max"
 mergeMaxFile "c:\\your_path_here\\MaxFileName.max"
 renameMerged objArray
 
 

This might not be the most streamlined way to approach the problem, but it should work. I’m not sure about No. 2, but hopefully this will get you started. Good Luck.

–Jon

Thanks a lot for the tips man! I’ll certainly use your advice!

Thanks again! :buttrock:

jonlauf, man, may I have another few questions?

Oks, here it is…

The scripts work perfectly, all I had to to was to swap the strings for my paths and organize it in my script. So, thanks once more!

But, I’d like to extend the script a little, first of all, I need to assign the new names to GEOMETRY objects only or better yet to objects only in a CERTAIN LAYER since I have it organized in layers.

Another thing would be to assign a specific name that’d contain a variable in the loops so that the objects could be named by their scene file increment they were in.

here’s your condition:

if ( findItem fooArray i.name != 0 ) then
 		(
 			i.name = "newName"
 			append mySelection i
 		)	

how do I append a variable to a string name? I remember from my high school VB classes we did it this way:

i.name = "newName" & a as string

where “a” would be the loop variable.

And as for the condition to select geometry only, it doesn’t work if I write:

if ( findItem fooArray i.name != 0 and classOf geometry) then
 		(
 			i.name = "newName"
 			append mySelection i
 		)	

Any tips would be very much appretiated man!