Jump to content

2 simple hdk questions


Recommended Posts

Excuse me for my silly & dummy questions, but i have two.

1. How can I build drop down menu for the attributes menu. I've done the following:

static PRM_ChoiceList pointAttribMenu( (PRM_ChoiceListType) (PRM_CHOICELIST_WILD|PRM_CHOICELIST_APPEND), SOP_mySop::buildPointAttrMenu );

PRM_Template(PRM_STRING, 1, &pointAttribParm, 0, &pointAttribMenu)

void SOP_mySop::buildPointAttrMenu(void *data, PRM_Name *theMenu, int theMaxSize, const PRM_SpareData *, PRM_Parm *){}

So the question is how i can get the list of attributes (and tokenize it for theMenu.setToken( " " ) ). Should i use GEO_AttributeHandleList ? And how ?

2. I want to calculate the distance between 2 points (of GEO_Point type). Can I do that non manually ? I cannot find appropriate method in GEO_Point class. I haven't found required method in UT_VectorX class too.

Link to comment
Share on other sites

0rr, thank you for the answer. i should find distance3d by myself. About the first question. I want to build choiceList for attributes menu (like attribPromote has). So i tried to use the same approach as SOP_CopRaster has (it is from the HDK examples, SOP_CopRaster::buildColorMenu member function). So far i could make a menu, but i can't understand how i could fill the list of the geometry attributes

post-4561-132735565907_thumb.jpg.

Edited by morzh
Link to comment
Share on other sites

  • 2 weeks later...

Hey,

about your second question, i guess the best thing if you at first try to build your menu, static, so you understand how a menu is generated

e.g.

static PRM_Name         frameRateMenuNames[] = {
    PRM_Name("kHours","Hours"),
    PRM_Name("kMinutes","Minutes"),    
    PRM_Name("kSeconds","Seconds"), 
    PRM_Name(0)   
};

if you got that, you can continue having a callback script that generates the menu for you.

e.g. whenever your node cooks, you store a list of attributes (AttributeDict) as member of your node, than you should be able to do something like this

SOP_mySop::buildPointAttrMenu(void *data, PRM_Name *theMenu, int theMaxSize, const PRM_SpareData *, PRM_Parm *)
{
    SOP_mySop   *sop = (SOP_mySop *)data;
    UT_StringArray attribs = sop->getMyStoredAttribList();
    for (i = 0; i < attribs.entries() && i < theMaxSize; i++)
    {
        theMenu[i].setToken( attribs(i).buffer() );
        theMenu[i].setLabel( attribs(i).buffer() );
    }    
    theMenu[i].setToken(0);
    theMenu[i].setLabel(0);
}

Cheers

Seb

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...