[Closed] get name from param instance?
In a scripted modifier I’m passing instances of the parameters around using &theParam, from that can I get its name property? like #theParam?
Here is some test code. From p I would like to get its name.
plugin modifier testMod
classID:#(1234,4321)
name:"Test Mod"
(
parameters testP rollout:testR
(
theParam type:#float
)
rollout testR "Test"
(
button printResults "print"
on printResults pressed do
(
p=&theParam
print p
)
)
)
b=box()
addModifier b (testMod())
max modify mode
select b
Here is the ugly method, anything better?
plugin modifier testMod
classID:#(1234,4321)
name:"Test Mod"
(
parameters testP rollout:testR
(
theParam type:#float
)
rollout testR "Test"
(
button printResults "print"
on printResults pressed do
(
p=&theParam
print (filterString (p as string) ":")[2]
)
)
)
Probably falls in line with this thread:
http://forums.cgsociety.org/showthread.php?f=98&t=659148
which unfortunately the best solution for actaully getting the name was the same as yours. It would be nice if there was a way to get struct and parameter names etc.
Casting to string isn’t so bad… it’s not as good as “.name” (doesn’t work), obviously.
Dare I ask why you’re trying to get the name of a parameter for which you’re passing the parameter by the actual name that you need… and, for whatever reason, can’t pass the name along with it?
Well that is a good question. I have an array of stuct data that I’m already using and I’m casting into the stuct instances of the parameters that I’m working with. I figured it would be faster looping through the array and setting values on the instances rather then setting property values. Speed is an issue in this as it is the facial control system that I have been developing using the dotNet pictureBox and it does have a bit of a speed hit. Not bad for what it is doing but I have wanted to keep things as fast as possible. I should have tried it with the setProperty and name values I guess. What I’m currently doing doesn’t have a speed problem so using the string method really isn’t a big deal. Unfortunitly it is one of those scripts that has gone though so many changes that I know there is lots that I could have done differently at this point but just don’t have time to go back and change it.