PDA

View Full Version : custom attributes question


ice799
09-22-2006, 02:21 AM
Hey guys --

I have a custom attribute defined like this:


classCAs = attributes classAttributes
(
parameters classParams rollout:classMaster2
(
mass type:#float ui:massSpinner
price type:#float ui:priceSpinner
class type:#string
karmaType type:#integer
)
rollout classMaster2 "Class Master" width:192 height:152
(
spinner massSpinner " Object Mass" pos:[32,8] width:117 height:16 range:[0,100000,1] type:#float
spinner priceSpinner " Price" pos:[32,32] width:117 height:16
radiobuttons karma "Karma Primitive" pos:[8,56] width:64 height:62 labels:#("Box", "Sphere", "Cylender")
button allofClass "All of Class" pos:[88,56] width:61 height:64
on allOfClass pressed do
(
local targetClass
for i in selection do (targetClass = i.class)
clearselection()
for i in objects do (if i.class == targetClass do selectMore i; print "selecting")
)
)
)
and I have code to add this attribute to the selected object in the scene:


on assign pressed do
(
for i in selection do
(
custAttributes.add i classCAs
i.class = classMaster.tv.selectedItem.text
)
)


So basically what I do is, I add the custom attribute to the object then I try to change its value.

For some reason, when I use the parameter editor, this custom attribute does not show up as being added to the selected object.

Any ideas what's up?

Sidenote: My c++ plugin says there are no custom attributes when using that code above, but when I use the "Parameter Editor" instead to add the custom attribute my C++ plugin says there IS a custom attribute.....

Thanks

PEN
09-22-2006, 11:39 AM
Well when you use the Attribute Editor it adds a Def Data string to the definition that stores all the information about the UI that cant be retrieved like the range of a spinner. It is this def data that is read by the Attribute Editor and I'm guessing is also read by the plugin.

ice799
09-22-2006, 01:42 PM
I assumed that the problem was that you need to create a string which holds the custom attribute text and then call Execute String -- this is how the file Macro_CustomAttributes.mcr does the custom attributes (this macro is the code for the parameter editor).

Could it be possible that you cannot set the parameter like I did with:


i.class = classMaster.tv.selectedItem.text


I hesitate to change my code to match the code in Macro_CustomAttributes.mcr until I'm convinced you cannot set the attribute the way I did right there.

Thanks.

PEN
09-22-2006, 02:01 PM
If you are just setting the attribute values you can do that with
setProperty $.theDef #theProperty.

ice799
09-22-2006, 03:44 PM
well sure, there are probably plenty of ways to do it.

My question was could there be some reason why doing it the way I did it, would prevent the SDK from seeing the custom attribute?

Is there some code someplace I can look at that adds custom attributes to an object??

I really would just liek to look at really simple code that does this and then test with my C++ plugin.

Thanks.

ice799
09-22-2006, 03:55 PM
So I'm a C/C++, assembly programmer. So with that in mind, what I REALLY want to do is somehow include Macro_CustomAttributes.mcr into MY maxscript and just call the functions I want directly...

Essentially what I am trying to do is create an easy to use UI that lets me assign some custom attributes to objects in the scene without having to do all the clicking and typing required by the parameter editor.

Is there someway I can just call the parameter editor's functions directly from my easy-to-use UI?

Also, if anyone has or knows where I can find some simple custom attributes code that adds an attrib to an object, I would really appreciate it.

Thanks.

PEN
09-22-2006, 03:58 PM
Well in Max script it is easy but I don't know if that is what you are looking for.


def=attributes test
(

)
custAttributes.add $ def



That will apply the attribute definition to the base of the selected object.

CGTalk Moderation
09-22-2006, 03:58 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.