[Closed] Identifying objects as references in maxscript
Hi,
Given 2 objects in max, is there any way to identify whether one object is a reference (i.e not an instance) of the other…? I know maxscript has the function areNodesInstances[font=Courier New] [/font]which identifies whether the 2 objects are instances of each other, but this returns false for referenced objects as you might expect, and there doesn’t appear to be an equivalent areNodesReferences[font=Courier New] [/font]function.
I guess one workaround would be to use brute force to directly compare the vertices/tverts/normals/etc of the objects but, as I’m required to iterate this over an entire scene of 100s of fairly detailed objects, I fear this would just be too slow!
Any thoughts…?
The definition of a Reference in Max is an object that shares a portion of the modifier stack with another object but not the complete modifier stack. Since the reference involves the BOTTOM portion of the stack being shared, this also means that the base object is instanced.
Thus, if you would check that the two objects are NOT instances AND their .baseobject properties are equal, you have a case of a Reference.
In fact, if you have two unique objects with unique modifiers and then call $Object01.baseobject = $Object02.baseobject, this will instance the second base object into the first and make them references!
Aha! That’s a seriously invaluable bit of info, should be very workable then it seems! Makes logical sense too really, although it probably would’ve never occurred to me to compare the .baseobject param
Many thanks!
instanceReplace[font=‘Courier New’] <dest_node> <src_node> can instance two objects completely,even instance an omni to a teapot:)[/font]
instanceReplace (Omnilight pos:[-100,0,0]) (teapot())
fn areNodesReferences node1 node2 =
(
local instances
InstanceMgr.GetInstances node1 &instances
(node1 != node2) and not (areNodesInstances node1 node2) and (finditem instances node2) != 0
)
denisT: Nice wrapper function, neatly done! Should come in pretty handy, thanks
feilang: Not really what I was trying to do but I appreciate you trying to help anyway!