Notifications
Clear all

[Closed] mergeMaxFile nodes to array

What is the best and easiest way to put the incoming merged objects into an array?
Without having to do the select properties of the mergeMaxFile?


delete objects
fxFile = @"C:\Users\Crabs User\Documents\3dsMax\scenes	est.max"
--//Merge New Particles system
mObjNames = getmaxfileobjectnames fxFile -- get the object names from the file
great = mergemaxfile fxFile mObjNames #AutoRenameDups #renameMtlDups --#select -- merge in the objects and select them
 
clearlistener()
print great

30 Replies

I’ve been using select and throwing selected into a layer right after the merge, but one thing that comes to mind is getting the scene objects before and after the merge…

scnObj = for o in objects collect o 
 fxFile = @"C:\Users\Crabs User\Documents\3dsMax\scenes	est.max"
 mObjNames = getmaxfileobjectnames fxFile -- get the object names from the file mergemaxfile fxFile mObjNames #AutoRenameDups #renameMtlDups --#select -- merge in the objects and select them
   postMergeObj = for o in objects collect o
   for o in scnObj do (
       local oIdx = findItem postMergeObj o
       if (oIdx>0) then (deleteItem postMergeObj idx)
   )
   print postMergeObj
   

It’s probably on the slow side though.

This is how I’ve done it in the past:

(
	firstObj = (objects.count)+1
	mergeMAXFile "file path here!"
	
	if objects.count >= firstObj do
	(
		lastObj = objects.count
		mergedObj = for objI = firstObj to lastObj collect (objects[objI])
	)
)
1 Reply
(@denist)
Joined: 10 months ago

Posts: 0

that’s what i am using for many years too. i don’t know a faster way.
the only problem is that doesn’t work with the #deleteOldDups option. so if we are looking for an universal solution it’s to merge with #select option and get selection after.
[left]
[/left]

Thanks guys for the different methods for use.
Rotu – Your snippet was the same thing I came up with when merging in objects. I was not sure if there was a less taxing way of doing it. I say taxing becomes some scenes I’m working in have mass amounts of objects.

I’ll test out the methods and see which is faster.

 lo1

why not just GetCurrentSelection() after the merge?

Why not use getNodeByName using the original mNameObjs to loop through? Probably be good to verify that the object is a valid object to begin with like this:


 objArr = for obj in mObjNames where (isValidnode (getnodebyname obj)) collect (getnodebyname obj)
 select objArr
 

-Eric

EDIT: Though with your current setup that may be an issue and you should probably replace #AutoRenameDups to #mergeDups to ensure the names from the original file will match those in the current file.

Hey Eric,
Thanks for the idea. My only concern with that is the name will not match after merging if there are duplicates. Max will autorename the objects. In return making getNodeByName not work properly.

I had initially tried that and it didn’t seem reliable.

I’ll try doing something along these lines.
Merge with #select and place that to an array, then restore the users original selection.

Hence my edit, from the maxscript help:

#mergeDups Ignore name conflicts, merge anyway resulting in possibly duplicated names.

Yeah, your right.
I’ll see what I can come up with and what works. I’ll be sure to let you guys know.
Thanks for the ideas guys.

This is damned crazy.

In my case I have to do this but handling duplicates.

One workaround I found (but I have to check if it’s correct), is to use getMaxFileObjectNames as you people did, and “guess” how 3dsmax will change the object names using uniqueName function.

I just hope that when you specify #AutoRenameDups, 3dsmax uses uniqueName, but who can tell…

Page 1 / 3