Taking that next step - Mergeing files

Hello

I created a tiny merge script that will merge in an object from a scene file. But I want to be able to search for multiple objects through multiple scenes.

example:

search a directory for any max scene files
search those scene files for any object with the words "sofa", "rug", "chair", etc...
and merge it into a current scene.

I need this to work inside of a texture baking script so I don't really want something with a UI or anything like "batchloader"

thanks

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
scottparris's picture

Awesome! It works exactly how

Awesome! It works exactly how I wanted it to.

Thank you again!

miauu's picture
miauu's picture

.

Yes, only one character is missing and this ruin the script. :)
Replace this:

searchForString = ("*sofa*", "*rug*", "*chair*")

with this:

searchForString = #("*sofa*", "*rug*", "*chair*")

and try again.
I tested and it work. :)

scottparris's picture

Thank you so much!!! This

Thank you so much!!! This looks great but I'm getting an error and nothing as of yet will merge into the scene.

From the listener:

-- Error occurred in n loop; filename: ; position: 397; line: 14
-- Frame:
-- n: "LR_Sofa_001"
-- called in mf loop; filename: ; position: 402; line: 15
-- Frame:
-- objToMergeArr: #()
-- mf: "V:\Collections\- Collections\Living_rooms\Living_room_001.max"
-- called in anonymous codeblock; filename: ; position: 598; line: 21
-- Frame:
-- No "map" function for "*sofa*"

Ideas?

miauu's picture

I don't have MAX to test it,

I don't have MAX to test it, but you will do it:

(
	maxFilesDir = getSavePath caption:"Select the directory" initialDir:"$scenes"
	maxFilesArr = getFiles (maxFilesDir + "\\*.max")
	searchForString = ("*sofa*", "*rug*", "*chair*")
	for mf in maxFilesArr do
	(
		objInFile = getMaxFileObjectNames mF
		objToMergeArr = #()
		for n in objInFile do
		(
			for str in searchForString where (matchpattern n pattern:str) do
			(
				append objToMergeArr n
			)
		)
		if objToMergeArr.count != 0 do
		(
			-- 	#AutoRenameDups	--	max2011+
				mergeMAXFile mF objToMergeArr /* #select  */#noRedraw #mergeDups #renameMtlDups #alwaysReparent quiet:true
		)
	)
)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.