[Closed] Position, rotation, and custom attributes
The code is great and gives me a list of attributes defined in the scene, but I want to return the name of a specific node with a known attribute.
If I add the attribute at one stage, I want to use maxscript to find the object with the attribute on it at a later stage.
Thanks very much, the help and pointers are appreciated.
here is a ‘professional’ 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
-- etc.
Denis, you should self-publish an e-book entitled: “Advanced MAXScript Prescriptions from the Max Doctor” I’d buy one! Let me know when it’s available. Seriously.
i’m thinking about it
btw… i know how to make my function above works ~30 times faster by changing only one word. who will find this word first?
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.
In some cases “collect” can produce much slower solution.
Anyway “appendIfUnique” with “append” method is the right one… I think
Also I often use this function by DenisT instead of “appendIfUnique”
fn _dts_uniqueArrays theArray =
(
hashes = #()
for a in theArray where (finditem hashes (h = gethashvalue a 0)) == 0 collect (append hashes h; a)
)
do you really think that changing “do to collect” or “append to appendifunique” can dramatically change a performance? i said try to make ~30 times (!!!) faster