[Closed] Custom Attributes
Hello from a fairly new maxscripter with a slight problem/confusion.
I tried googling and searching various forums for a solution for my problem, but unfortunately was unable to find one. But on the positive side I got my first reason to post something here.
So I have been trying to save all the information from an attribute holder that the user has added bunch of spinners to via the parameter editor window. Since for what I’m trying to do I need to be able to re-create the same attribute holder in a different controller later on (by reading the saved information from a file). So it is not just as simple as copying the custom attribute definition and applying it to another object, but instead I need to save all of it’s necessary information.
so what im trying to do is save all of those spinners, their current values and the text applied to them.
And im trying to do this without using their names unless I get their names by some way. So ideally I should be able to go through all of them in a for loop and access each attributes text, class, value and find out if they are a spinner or a slider.
And I’m not sure if I’m completely lost with this, but the only way to really access those values/information is through a parameter block? And so far I have no idea how to work with parameter blocks and haven’t managed to find anything clear enough on it either.
I hope somebody will be able to help me with this problem or at least point me in the right direction.
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?
:¬)
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.
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
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?
first of all we need to find all custom attribute definitions and their instances…
if a custom attribute was created using MAX user interface and it was not redefined later it’s name is #Custom_Attributes
so to get all these attributes we can to it as:
fn findCustomAttributesDefs =
(
for def in custattributes.getSceneDefs() where def.name == #Custom_Attributes collect def
)
after that we need their instances:
defs = findCustomAttributesDefs()
for def in defs do (inst = custattributes.getDefInstances def)
every instance has rollout where our spinners are, and name of this rollout is #Params
so we can find all spinners as:
for c in inst.params.controls where iskindof c SpinnerControl do (…)
if we found spinner we can get its data…
now it’s all together:
fn findCustomAttributesDefs =
(
for def in custattributes.getSceneDefs() where def.name == #Custom_Attributes collect def
)
defs = findCustomAttributesDefs()
fn findCustomAttributesSpinnerData definst =
(
for c in definst.params.controls where iskindof c SpinnerControl collect
(
SpinnerData name:c.name text:c.text value:c.value range:c.range
)
)
(
struct SpinnerData (name, text, value, range, param, type, default)
for def in defs do
(
format "def: %
" def
for definst in custattributes.getDefInstances def do
(
format " def instance: %
" definst
data = findCustomAttributesSpinnerData definst
for sp in data do format " spinner => %
" sp
)
)
)
as you can see there are three properties in SpinnerData (type, param, and default) which could be nice to get but we can’t do it using only spinner data. These things are a part of spinner definition. which we can get only by parsing attributes definition source code:
source = custattributes.getDefSource def
it will be your homework
Thanks for the quick reply. I will hopefully find the time soon to look into that in more detail.
After running into that problem I had to do something else for the time being leaving that project for my free time which I haven’t had enough of.
But yea I had trouble finding/accesing the SpinnerControl when I was first trying that stuff which I think was the main reason I got so stuck with the problem.
So thanks again and I will try to find the time to do my homework