Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk 3ds® Max® / MaxScript / Knowing if an object has Custom Attributes
  RSS 2.0 ATOM  

Knowing if an object has Custom Attributes
Rate this thread
 
51104
 
Permlink of this thread  
avatar
  • Total Posts: 12
  • Joined: 05 July 2010 03:22 PM

Hi,
I’ve been having this problem at my job where I need to go through a scene’s objects and check if they have a custom attribute on them. Whenever you try to access one of the C.A properties of an object that has no C.A applied , it returns an error.

Thus the solution for now is to do a try()catch(). But on a large group of objects , the UI (dotnet) becomes slow because of that check. When I did put that checkup part under comments,
the process was much faster.

So the question is: Is there a way to ask to an object if it has been assigned with a specified custom attribute. Returning a true / false , an empty list or whatever! As long as it’s not an error!

Thanks in advance!



Replies: 0
avatar
  • Location: West Midlands, England, UK
  • Total Posts: 14445
  • Joined: 06 August 2007 11:06 PM
  • Permlink of this post

custAttributes.count <obj> [baseObject:<bool>] maybe?



Max 4.2 through 2013.
XP-64 (SP2)
NVidia 9800GTX-512 (Driver 266.58).
Core 2 Quad Q6600 2.4GHz, 8Gb Ram, DX9.0c.

Replies: 0
avatar
  • Anubis
  • Posted: 07 January 2011 01:37 PM

Also can test for concrete property using isProperty() function

for obj in objects where isProperty obj #roundness do ...


Max 9 through 2009, XP-Pro x64 SP2
ASUS EAH3450 Series (Driver 8.470).
Core 2 Duo E8400 3GHz, 4Gb Ram, DX9.0c.

Replies: 0
avatar
  • lo_
  • Posted: 07 January 2011 10:42 PM

I believe isProperty is just a wrapper for try/catch, it takes the same amount of time to execute as try/catch if the result is false.



VFB+ : An enhanced 3dsmax frame buffer (free)

Replies: 1
/img/forum/dark/default_avatar.png

yep, i not tested it runtime before and i see some sense in this conclusion.

[edit] custAttributes.count looks enough if the scene has only one attribute, else - need to test their names. maybe this snippet looks more promising:

for obj in objects where custAttributes.count obj do (
   
objCAsNames = for ca in (custAttributes.getDefs objcollect ca.name
   
if findItem objCAsNames #CA_Name_Here > 0 do (
      
-- ...
   )
)
Author: Anubis

Replied: 08 January 2011 03:35 AM  
avatar

Thanks alot guys, looks like i haven’t been enough through the help files or haven’t it done properly. This last solution works perfectly well, very apreciated!

See ya!



Replies: 0