Notifications
Clear all

[Closed] List of objects merged

Hey, does anyone know of a way to get a list of the objects you just merged into your scene using the mergeMAXFile command? Or do you have to make an array of all scene objects before the merge, then another after, and find out the difference? Thanks.

  • Neil
20 Replies

Yep just like this annoyingly!

Merging is one area of Max that I’d love to see improved for both UI and script access. Merge by Layer should be in the UI and by script.

Damn. Well, the comparing the scene is a bad idea, because if I have 10,000 objects in the scene, the comparison takes approx 10,000×10,000 operations, which is a long wait. Any advice on a faster comparison maybe?

  • Neil

There are two ways that I use, select nothing and then merge in using #select or do a comparison.

(
max select none
local mergedObjs = #()
local pObjects = objects as array
Mergemaxfile @"C:	emp	est.max" #select
for o in objects where finditem pObjects o == 0 do append mergedObjs o

mergedObjs
(selection as array)
)

Selecting won’t work, as if you merge in an object that exists on a hidden layer, the moment it merges it in deselects the object. So I’ll have to do the comparison. But I need to find a faster comparison method so I’m not actually testing every element in array 1 with every element in array 2.

  • Neil

Maybe something clever with handle IDs?

sOldHandle = objects.count

mergemaxfile @"c:	emp\Merge_A.max"

theobjs = (for o in objects where o.inode.handle > sOldHandle collect o)
1 Reply
(@artofsoulburn)
Joined: 10 months ago

Posts: 0

That is brilliant Dave. Didn’t know handles even existed. Thanks so much.

  • Neil

Neil have you actually tested the finditem method for performance? I doubt testing with an array of 10000 objects would take more than 1 second.

EDIT: It’s probably the actual merge function that is taking the most time. set some timestamps and check

1 Reply
(@artofsoulburn)
Joined: 10 months ago

Posts: 0

It’s not the merge, its def the comparison. But I was using a different method than finditem, maybe that was the issue. Either way, the handle idea seems to be the better way to go. But thanks for the info!

  • Neil

i would go for the finditem method over the inode handle or at the least check all scene nodes and find the maximum value first. IIRC the max value is not always equal to objects.count

3 Replies
(@davewortley)
Joined: 10 months ago

Posts: 0

When would they not?

(@davewortley)
Joined: 10 months ago

Posts: 0

Particle Flow would be a good example of when they wouldn’t match… each operator has a handle but doesn’t appear in the objects array, this would also apply to the merge #select and comparison methods.

What else apart from pFlow operators can take this hidden form? And how do we get a true objects list? I’m sure I’ve looked at it before but now I can’t remember…

(@artofsoulburn)
Joined: 10 months ago

Posts: 0

Oh, I was going to do that anyways just to be sure (check all the objects for the maximum handle value), but otherwise that seems to be the fastest method. Thanks for the warning.

  • Neil

But if you do sOldHandle = $*.count, wouldn’t that pick up any stragglers? Seems to work for me, even when I use pflow (and may I say, I so hate that pflow creates those hidden nodes, such a pain, especially when merging.)

  • Neil

ok… first of all of course the highest handle in the scene bigger than number of nodes.
second – to get an inode handle is much slower than anim handle.

so on pre-merge phase collect all anim handles and found the maximum
the simplest code is:

max_id = amax (for node in objects collect (gethandlebyanim node))

it should take almost noting for 10k node scene
on post-merge phase go through all nodes again and collect all which handle higher than previous maximum:

merged = for node in objects where  (gethandlebyanim node) > max_id collect 
node

my guess is this check shouldn’t take more than 0.2 sec for 10,000 nodes.

Page 1 / 2