PDA

View Full Version : Custom Attributes


_stev_
01-25-2006, 12:40 AM
I can't seem to figure out how to add a custom attribute to an object. I keep getting "requires MSCustAttribDef" errors. How do I set this up?

Please help,
Stev

PEN
01-25-2006, 01:23 AM
Have a look at this tutorial on my site "Calling Custom Attributes from Script Controllers:", one of the first things that I do is create a ca def and add it to an object.

_stev_
01-25-2006, 05:51 AM
I checked out the tutorial. Thanks, that helped me understand this stuff a little better. But if I want something besides a function in the definition, how how is that done? I want an attribute on an object I can use in an expression on another controller, or use manually in the interface.

Thanks for the tutorial PEN.

Stev

PEN
01-25-2006, 11:40 AM
This should help you out. Run the script to see what it all does.



--Make some objects and add a blank modifier to the box
b=box()
s=sphere()
eM=emptyModifier()
addModifier b eM

--Create the defintion for the custom attribute
def=attributes testAttrib
(
--Parameter block to store the tracks of animation
parameters testP rollout:testR
(
--A track of animation
--Look under scripted plugins for the types that can be used.
animationTrack type:#float UI:mySpinner
)
--The rollout that will show up in the modifier panel.
rollout testR "test"
(
--The spinner that is connected to the animationTrack
spinner mySpinner "My Spinner"
)
)

--Add the definition to the emptyModifier
custAttributes.add eM def

--As a test wire the radius of the sphere to the param block 2 track.
paramWire.connect eM.testAttrib[#animationTrack] s.baseObject[#radius] "animationTrack"

max modify mode
select b

_stev_
01-25-2006, 04:25 PM
Right on! That was exactly what I needed. Thanks so much.

Stev

Chinwagon
01-25-2006, 10:59 PM
er... can I just jump on the back of this thread to ask a question (or two)?
Why don't custom attributes made through maxscript ever show up in the parameter editor? Is there a way of constructing CAs in maxscript that do show up in it?
:¬)

PEN
01-26-2006, 01:42 AM
CA's dont show up in PE because one they don't have the right name, I think that it needs to be "custom_attributes" and also you need to provide it with defData that if formated correctly.

You need this defData because in Max you can't query a parameter for what UI item it is connected to so you can't get things like the range of a spinner. You need to store this data in defData in the right format. Rip open parameterEditor to find out what the format is.

_stev_
01-26-2006, 06:47 PM
Hey PEN,

After doing the tuts on your website, I'm interested in using script controllers or exressions to achieve secondary motion mathmatically not dynamically. I looked at a script on Comet's site that does this, but you have to "bake" the animation. I'm looking for something that updates interactively. Do you have any suggestions?

Thanks again,
Stev

PEN
01-27-2006, 02:20 AM
Well the spring controller already does this. Trying to do it in Max script would be slow I would think. I haven't really tried, I have looked at doing it but I have never followed through thinking that it wouldn't be worth it.

Bobo, do you have anything to say on this?

CGTalk Moderation
01-27-2006, 02:20 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.