PDA

View Full Version : Help with dynamic naming of custom attribute rollout name...


CrazyDamo
09-28-2011, 11:54 PM
Yullo All,

I'm trying to script some custom attributes to a simple box object in order to store some information about the layers in the scene. My issue is that, I need to store several separate parameters, and I can't seem to code/script a unique name for either the Custom Attribute name or the rollout parameter name, or even the editable box unique name. I have tried using a variable to assign the name, but get errors, I have also tried using a for loop inside the rollout creation component, in order to add several 'edittext' box's of separate names... but get errors...

The following is the basic setup:


fn createCustomAttrs layerArgs=
(
renderLayersCA = attributes "LayerList"
(
parameters main rollout:params
(
attrNameType type:#string

)--end parameters
rollout params "Render_Layer"
(
edittext attrName_EB "Layer Names" fieldWidth:200

)--end rollout
)--end attributes
)--end function



but this is what I want to do:



fn createCustomAttrs layerArgs=
(
renderLayersCA = attributes "LayerList"
(
parameters main rollout:params
(
for x = 1 to layerArgs.count do
(
attrTypeName = "LayerInfo_" + x
attrTypeName type:#string
)--end for loop

)--end parameters
rollout params "Render_Layer"
(
for a = 1 to layerArgs.count do
(
editTextUniqueName = " attrName_EB_" + a
edittext editTextUniqueName "Layer Names" fieldWidth:200

)--end for loop

)--end rollout
)--end attributes
)--end function
layerInfoArray = #("Info1", "Info2", "Info3")
createCustomAttrs(layerInfoArray)


but this produces errors. Any help would be great. I'm usually working in Maya with Python but need to work in Maxscript.. finding the lack of doco to be a tad tiresome :)


Cheers

D.

elT
09-29-2011, 12:19 AM
One thing i notice :
editTextUniqueName = " attrName_EB_" + a

where a is an integer, you should convert it to string
editTextUniqueName = " attrName_EB_" + (a as string)

You have multiple instances of this, just add (X as string).

This might not be all of it, though.

CrazyDamo
09-29-2011, 12:38 AM
Thank you - I'll ded do that in future. Looks like all the python has made me a little lazy on stuff like that :)

CrazyDamo
09-29-2011, 12:42 AM
Just been reading a little more .. and I think I may be aproaching this the wrong way. I'll explore the use of "AppData" instead of custom attributes.. which seems to rely heavily on UI based shinanigans - which doesn't seem very friendly :

http://www.gamedev.net/topic/374572-custom-data-in-3ds-max/

At the end of the day I'm trying to store information that doesn't require a UI for the user - just storage of info for another script - that can be saved with the file.

MattRennie
09-29-2011, 08:55 AM
Hey Damo!

Have you tried just storing your data as user properties (setUserPropBuffer)? Its quick and dirty.

PEN
09-29-2011, 12:27 PM
AppData is only good for storing strings, so any value will need to be converted back to what you needs. A CA Def doesn't require you to do this as it can the data stored as is. You don't need a UI in a CA Def as you can just add a parameter block without a rollout. You should have need in my scripting class yesterday as we did just this.

The only real concern with a CA Def is there is overhead of the def in the scene. I personally have never had an issue with that now ever.

PEN
09-29-2011, 12:30 PM
Just looked at that link from 2006 they you posted on gamedev. I don't know why he says those two methods are not good and he doesn't say way. I see no issues with either of them.

CrazyDamo
10-13-2011, 01:17 AM
Heya
Now that I have come out of the blur of the last week - just wanted to say thank you to all the replies.

PEN - Yeah the link was very old. I ended up using the User Defined Object Properties on a proxie mesh 'box'. This may seem a little basic but the reult seemed to work ok - the overhead of reading and writing to the object properties is neglagble.

Matt!!! You glorious man child. So good to hear from you - will mail you offline to give you an update of life this side of the equator. The setUserPropBuffer is something I will look into for future stuff.. when these folks give me time to think.

CGTalk Moderation
10-13-2011, 01:17 AM
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.