getOwnersByAttributeDef


#1
http://forums.cgsociety.org/archive/index.php/t-1126796.html

how would I go about selecting a node(s) that have attributes like this on them and collecting them or it?

here is a ‘professional’ :wink: version:
fn getOwnersByAttributeDef attrDef = if isMSCustAttribClass attrDef do
(
local owners = #()
for attr in (custattributes.getDefInstances attrDef) where (owner = custattributes.getOwner attr) != undefined do appendifunique owners owner
owners
)

that collects unique owners of the ca with a specified ca definition. if you looking for a specific owner class you have to add filter, like:
isvalidnode owner
–or
iscontroller owner

this function works in general case, but if you know what you need to find and where to search the method might be modified to works faster.


before any things thanks so much to denisT he is really so helpfull for maxscript Users .
i think theres is no need for two Array and Append
fn getOwnersByAttributeDef attrDef = if isMSCustAttribClass attrDef do
(
local owners = #()
owners = for attr in (custattributes.getDefInstances attrDef) where (custattributes.getOwner attr) != undefined collect attr
)