PDA

View Full Version : list of parameters?


TiSna
03-07-2008, 09:47 AM
Hi everybody,

i was wondering how to collect a list of the parameters from a modifier by scripting?
for example, if you have a "bend" modifier on your object, you have parameters like ("center", "gizmo", "angle"...), and if you do $.modifers[1].center, you can access the value. But if you dunnot know especially that the modifier is bend, and you don't know what could be the parameters, how to have a list of them for a random modifier?

thx for helping,
remi

JHN
03-07-2008, 10:21 AM
try:

show $.modifiers['yourmodifier']

-Johan

TiSna
03-07-2008, 10:24 AM
try:

show $.modifiers['yourmodifier']

-Johan

eh eh thanks, it works but except for attribute holders, or custom attributes. it returns a blank list. maybe there is no way for this kind of modifiers to have them?

PEN
03-07-2008, 11:13 AM
getPropNames $.bend.custom_Attributes
getSubAnimNames $.bend.custom_Attributes

First gets all the names of the properties on the object. Second gets all the animation tracks. You need to know when to use one or the other.

getPropNames you can use with get/setProperty.
getSubAnimNames you can use to get just the animation tracks as well use it when you need to know the name of tracks for wiring.

PEN
03-07-2008, 11:22 AM
I should also mention, to find out if there is a custom attribute def on something you can do...

numAttribs=custAttributes.count $.bend

and then then loop through all the defs on that object with

for i = 1 to numAttribs do print (custAttributes.get $.bend i)

TiSna
03-07-2008, 12:42 PM
getPropNames $.bend.custom_Attributes
getSubAnimNames $.bend.custom_Attributes

thanks for your answer paul, it will help :)

but for the "bend" modifier, it was just an example that i have taken
maybe you will be well-informed about that, my real problem is :
i have some personal controllers for a rig like for example "R_foot_control", with a custom attribute holder on it named "footctrl". With this CA, i can control some sliders like "footroll", "bank"...

i'm building a script about this, and as for each controllers, it wouldn't be the same names for these sliders, how can i obtain the list of these sliders for each of my nodes?

i don't know if you seee what i mean, but to illustrate, if i write
$.modifiers[1].footroll, it will recognize the existing property and it will return to me the current value. But it works only coz i know the name of this property, that's why i wanna obtain a list of these properties. To use them after in a loop.

Thks,
remi

TiSna
03-07-2008, 02:45 PM
i have tried something like that :
bb=custattributes.getdefs $.modifiers[1]
for k = 1 to bb.count do (
print bb[k].source
)

and it results :

#(<AttributeDef:footCtrl1>, <AttributeDef:footCtrl2>)
"attributes footCtrl1
(
parameters footP rollout:footR
(
footroll type:#float ui:(footrollSp, footrollSl)
bank type:#float ui:(bankSp, bankSl)
)
rollout footR "Foot Controls"
(
spinner footrollSp "" range:[-1,1,0]
slider footrollSl "Foot Roll" range:[-1,1,0] offset:[0,-20]

spinner bankSp "" range:[-1,1,0]
slider bankSl "Bank" range:[-1,1,0] offset:[0,-20]
)
)
"

"attributes footCtrl2
(
parameters footP rollout:footR
(
Footext type:#float ui:(footextSp, footextSl)
)
rollout footR "Foot Controls +"
(
spinner footextSp "" range:[-1,1,0]
slider footextSl "Foot Toes" range:[-1,1,0] offset:[0,-20]
)
)
"

OK

i have my 3parameters "footroll", "bank" and 'footext" that appears and the definition of all of my CA, but i don't know what function to use to catch their names?

TiSna
03-12-2008, 02:20 PM
no other idea?

PEN
03-12-2008, 02:30 PM
Sorry I will try and find time to respond later to this.

dmak
03-12-2008, 04:15 PM
Remi,
I'm working on this now as well. I think Paul answered the question earlier.

The trick here is knowing what the name of the Custom Attributes definition is. I'm rewriting my definitions to always have the same name. So footRcntrl and footLcntrl will always use the same definition name like "animation_props" or something to that effect. This way I can always get my cntrl object properties (getPropNames $Node_Name.animation_props).

EDIT:
Actually after looking at it a little longer, here's what you can do so that you can get any custom attribute (Paul also mentioned this):

for i = 1 to (custAttributes.count $.modifiers[1]) do
(
defName = custAttributes.get $.modifiers[1] i
propNames = getPropNames defName

for p in propNames do
(
print p
)
)

propNames will return all the propertied in the custom attributes definition on your object.

Seems like that makes the most sense.

dan

TiSna
03-13-2008, 09:13 AM
eeeh thanks to paul and dmak

Indeed, the functions was good. I just had not used the right syntax, that's why it wasn't work!!

thx for helping me

PEN
03-13-2008, 10:59 AM
THanks for jumping in Dan.

TiSna
03-27-2008, 09:45 AM
In the same order, i wanna check the existence of the property in the definition of a CA.
I mean, if you have a CA property like "$.modifiers[myCustAtt].foot" for example, if the slider "foot" exists on your CA, it will return the value and if not, you will have an error message (and not unfortunately "undefined" :-( ).
So, i have searched if there is a function to test that, but i didn't find anything. i don't know if there is a simple way like "if $.modifiers[myCustAtt].foot !=undefined do ..." or something similar to do it.

thks, remi

JHN
03-27-2008, 11:15 AM
Use a try()catch() function to trap errors when trying to acces the value.

-Johan

TiSna
03-27-2008, 11:30 AM
thanks, it's perfect! :)

CGTalk Moderation
03-27-2008, 11:30 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.