PDA

View Full Version : CustAttributes Help


SoLiTuDe
11-03-2008, 06:30 PM
I'm currently dealing with adding custattributes to objects in a scene. I can create / add the cust attribute fine, but the problem I'm having is that I can't figure out how to have the script check to see if the attribute is already declared in the scene, so everytime I run the script it adds another custattribute to the scene.... so custattributes.getscenedefs() will keep getting bigger and bigger and bigger... not what I want.

global scenedef = true
sceneattrib = custattributes.getscenedefs()
for o in sceneattrib do
(
if (matchpattern o.name pattern:"*asset*" ) then
(
Print "Asset Def Found... continuing."
scenedef = true
exit
)
else if ((matchpattern o.name pattern:"*asset*" ) == false) then
(
Print "Asset Def not found."
scenedef = false
)
)

if scenedef == false then
(
global addassetdata = attributes assetdata
(
parameters data
(
Asset type:#string
)
)
print "Adding Scene Def"

)

eek
11-04-2008, 02:46 AM
local object = $point01

if object.testca == undefined do
(
testca = attributes testAttributes
(

)
custAttributes.add testca object #unique
)

Or just get the count of custAttributes of the object, if its larger than 0 add it if not dont:

if (custAttributes.getDefs object).count < 1 do
(
-- add your custom attribute here.
)

SoLiTuDe
11-04-2008, 02:36 PM
Thanks for the help! I decided to go with including the custattr. in startup, so I will just check to see if it's added to the objects or not, like you suggested. :D

CGTalk Moderation
11-04-2008, 02:36 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.