API - find out which Option is selected

   3602   4   0
User Avatar
Member
229 posts
Joined: May 2006
Offline
Hi,

how could i find out which Option of my Selectionbox is selected ?

i've created a Selector Parameter


static PRM_Name singleParticleDrawOptionNames =
{
PRM_Name(“drawParticleComponentNone” ,“none”),
PRM_Name(“drawParticleComponentSpring” ,“Springs”),
PRM_Name(“drawParticleComponentDisplacement” ,“Displacement Vectors”),
PRM_Name(“drawParticleComponentAll” ,“all”),
PRM_Name(0)
};

static PRM_Name displayNames =
{

PRM_Name(“drawParticleCSelector” ,“Draw Components”),
PRM_Name(0)

};


PRM_ChoiceList specparticleDrawOptions(PRM_CHOICELIST_SINGLE,singleParticleDrawOptionNames);

PRM_Template(PRM_INT, 1, &displayNames,0,&specparticleDrawOptions)


i tried to access the stuff using


int DRAWPARTICLECOMPONENT_SPRING(VOID) { INT_PARM(“drawParticleComponentSpring” ,ILF_DRAWPARTICLECOMPONENT_SPRING, 0, 0) };


but it doesnt work,
i always got an error message telling me:

frequenzForce1 evalInt: Invalid parameter index drawParticleComponentSpring


can somebody please tell me how to get the Options which are selected ??

thx in Advance

Sebastian
User Avatar
Staff
5156 posts
Joined: July 2005
Offline
You have to query the parm name, not the menu item name.

so:
INT_PARM(“drawParticleCSelector”, ILF_DRAWPARTICLECOMPONENT, 0, 0) };
will tell you the index of the selected option (for Springs, index=1). Only one option can be selected at a time (otherwise, you'd have to use a series of PRM_TOGGLE parms).
User Avatar
Member
7714 posts
Joined: July 2005
Offline
Personally, I find it a lot easier to just use the eval*() versions of the functions that use the parameter name. A lot less prone to error even if they are less efficient. And if you only evaluate your parameters once per cook, there's very little to lose. And if you really do find it to be a bottleneck, you always easily switch to the index versions later.
User Avatar
Member
229 posts
Joined: May 2006
Offline
Hi,

actualy the code you've posted didnt work out, but i was wondering if the
enum i've created



enum POP_FrequenzTestIndex
{
ILF_ACTIVATE, // 0
ILF_SOURCE, // 1
ILF_ORIGIN, // 2
ILF_DIR, // 3
ILF_RADIUS, // 4
ILF_LENGTH, // 5
ILF_STRENGTH, // 6
ILF_IGNOREMASS, // 7
ILF_OVERRIDEMASS, // 8
ILF_MASS, // 9
ILF_GRAVITY, // 10
ILF_INTERACTIONRADIUS, // 11
….


and using this elements to access UI elements are somehow connetected.


So the ordering of this enum elements and the appearance of the UI elements when i create them, maybe connected somehow or something like this ?? is this possible or what do i need these enum stuff for ???


thx in advance

Sebastian
User Avatar
Staff
5156 posts
Joined: July 2005
Offline
As Ed mentioned, it's better just to use

int val = evalInt(“drawParticleCSelector”, 0, 0);
and forget about the enums altogether. We build a name hash table, so it's not like it's looping though all the parms doing strcmp's. INT_PARM was added long before this was the case.
  • Quick Links