MAXScript Custom Attribute problem

MAXScript Custom Attribute problem

Anonymous
Not applicable
1,198 Views
11 Replies
Message 1 of 12

MAXScript Custom Attribute problem

Anonymous
Not applicable
I'm wondering if anyone has seen this problem. I add a custom attribute to an object and save the file. Without closing max I re-open the file. All my custom attribute spinners read zero. When I query the parameters via maxscript I get all the correct values, so the attributes have in fact been preserved. if I try to change a spinner value I get the "attempt to access a deleted scene object" message. The custom attribute was created with #unique. Furthermore, if instead of re-opening the file in the same max session I completely close out of max and restart it, then when I open the file the parameters are indeed showing correctly in the spinners.

I know I'm missing something but I have no idea what it could be. Any help is appreciated.
0 Likes
1,199 Views
11 Replies
Replies (11)
Message 2 of 12

Anonymous
Not applicable
I have the exact same problem... In my case my CA aren't #unique'd but the same thing happens a lot, I can fix it manually if I re-run the script after making any change to the custom attribute definition. And i really mean ANY change, even inserting an space character will make my spinners come back from death. Did you find a solution?

Thanks in advanced,

Juan G. Campa
0 Likes
Message 3 of 12

Anonymous
Not applicable
No I haven't. I've done more searches, etc but just can't find anything. We're just living with it for now.
0 Likes
Message 4 of 12

keithm
Enthusiast
Enthusiast
What Version of Max? I'm still on 9 and haven't seen this..

Can you make a single item CA and show the issue?
0 Likes
Message 5 of 12

Anonymous
Not applicable
It's pretty easy to duplicate. I'm on 3ds Max 9. Do the following:

1. Use the sample CA code from the Maxscript help file:


weaponDataCA = attributes weaponData
(
parameters main rollout:params
(
hitPoints type:#float ui:hits default:10
cost type:#float ui:cost default:100
sound type:#string
)
rollout params "Weapon Parameters"
(
spinner hits "Hit Points" type:#float
spinner cost "Cost" type:#float
dropdownlist sound_dd "Sound" items:#("boom", "sparkle", "zap", "fizzle")
)
)

custAttributes.add $sphere01 weaponDataCA


2. Make a sphere and run the script to attach the attribute to $Sphere01
3. Save your file.
4. Now open the file without closing Max.
5. Select the sphere. All the CA spinners will show 0.00
0 Likes
Message 6 of 12

Anonymous
Not applicable
Ok, here's an example:


global TestAttribute = attributes TestAttribute
attribID:#(0x14ef2451, 0x750fbe76)
(
parameters main rollout:prop
(
TheValue type:#float ui:spinny
)
rollout prop "Stage properties"
(
Spinner spinny "The value is"
)
)


I assign it to an object using

 custAttributes.add $ TestAttribute 


everything ok so far...

I re-run the attribute script, everything ok
I re-run the script again... Boom! spinners dead.
I re-run the script again... Not working.
I re-run the script again... Nothing, they're dead.

I insert a space anywhere in the attribute definition above and hit ctrl+E and the spinners come back to life.

There you go, can you test this?

Thanks,
Juan G. Campa
0 Likes
Message 7 of 12

Anonymous
Not applicable
BTW, I'm also using Max 2009...
0 Likes
Message 8 of 12

Anonymous
Not applicable
I also noticed that the buttons from the CA's rollout never stop working...
0 Likes
Message 9 of 12

keithm
Enthusiast
Enthusiast
For the Values of a CA to save with the file, they need a attribute class ID, otherwise, as stated in the help "Attribute definitions without attribID's are private to the current MAX session."

So adding an ID is step one...also:

The sound type should be a #integer type, not string to store an integer index of the array.

The UI element of the Sound needs to be linked to the dropdownlist.



********* StartCode


weaponDataCA = attributes weaponData
attribID:#(0x130a5ca3, 0x70571c5a)
(
parameters main rollout:params
(
HitPoints ui:hits_sp type:#float default:10
Cost ui:cost_sp type:#float default:100
Sound ui:sound_dd type:#integer default:1
)
rollout params "Weapon Parameters"
(
spinner hits_sp "Hit Points" type:#float
spinner cost_sp "Cost" type:#float
dropdownlist sound_dd "Sound" items:#("boom", "sparkle", "zap", "fizzle")
)
)

custAttributes.add $'sphere01' weaponDataCA


********* EndCode

* hate the code coloring on this site!
0 Likes
Message 10 of 12

Anonymous
Not applicable
Keith,

This still does not work. The issue is not that it isn't saved with the file. If I close MAX and re-launch it, then open the file the settings are there - no problem. The issue is if you re-open the file WITHOUT CLOSING MAX, then the values go to zero. Adding the attribID did not fix this. If that is actually working on your machine, then there must be something about certain installations that is causing this.

Ken
0 Likes
Message 11 of 12

keithm
Enthusiast
Enthusiast
Process:
Open Max
Create Sphere
Run Script pasted in to a "new script" to Apply Mod.
Save Max File
Open Max File


I get the default values in max 9 and 2009 appearing when selecting the sphere after opening. Did this with my code example and your 'Stage Properties" spinner example. Worked as expected.

I'm not familar with the "$" part of your CA.add call... What's that? It causes an error on my system. or is that just 'The Area' reformatting code for you? sooo helpful...
0 Likes
Message 12 of 12

Anonymous
Not applicable
That works for me too, the problem is when I re-run the script... Try running the script several times without closing or reopening the .max
0 Likes