Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Delete a userprop

Delete a userprop

Anonymous
Not applicable
954 Views
6 Replies
Message 1 of 7

Delete a userprop

Anonymous
Not applicable
Is there a method to delete a user property? Without having to parse and edit the userPropBuffer directly?

Thanks,
Ben
0 Likes
955 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable
Not directly (without userpropbuffer) or the helpfile is lacking some documentation, but why would you want to delete it? Wouldn't assigning undefined or NULL to it work?

-Johan
0 Likes
Message 3 of 7

Anonymous
Not applicable
Why would I want to delete it? I think it'd be responsible that, if a script could make a new user prop, it should also be able to remove one.

If I setUserProp to undefined, then I end up getting the string "undefined" from getUserProp. Note, it's the string, not "undefined" the object.

For example:

1. start a new max file, make a dummy node, select it.
In MaxScript Listener:
2. getUserProp $selection "myProp" (returns undefined)
3. setUserProp $selection "myProp" 12345
4. getUserProp $selection "myProp" (returns 12345)
5. setUserProp $selection "myProp" undefined
6. getUserProp $selection "myProp" (returns "undefined", a string, not undefined)
0 Likes
Message 4 of 7

Anonymous
Not applicable
I do understand it returns the undefined as string... I was merely trying to add some suggestions to the lacking support of deleting userprops... so you could filter on "undefined" or "NULL"...

If you really want them destroyed you should use userpropbuffer and do some string functions, wouldn't be too hard, but I agree it's not a simple clean solution.

-Johan
0 Likes
Message 5 of 7

Anonymous
Not applicable
On a related topic, I have a script that was making 20-25 userprop calls per object, and it took forever to run. I recently redesigned it to read in the entire buffer, do all of my edits in a stringStream mode, then write the buffer back out. It took my total script execution time from about 5 minutes down to 20 seconds or so... The getUserProp and setUserProp functions are really expensive in my experience.

Oh, and for some reason, when creating the userProp buffer, you need to use "\r\n" at the end of each line, whereas "\n" is all that's needed for nearly any other multi-line string.
0 Likes
Message 6 of 7

danlane3d
Contributor
Contributor

Do you still need this? 😄
deleteUserProp
<node> <key_string>

0 Likes
Message 7 of 7

denisT.MaxDoctor
Advisor
Advisor

I think that, after almost 20 years, this property—if it hasn’t already managed to delete itself—has long since lost any value. 😅 👍

0 Likes