Jump to content

group parameter ( ? )


Recommended Posts

hi ,

im trying to add an ' group parameter ' to one of my OTLs , similarly with the ones that most of the built-in tools have .

obviously im failing . so ( if you ever did / know how to replicate that ) can anyone help me ?

post-5487-130990416969_thumb.png

--

i know i can use a ' string parameter ' , but the glory of that mini-pop-up-of-who's-available-list .. isnt available ( aparently )

the only ones that have a similar ' feature ' are the file parameters .. but i cannot find any trace of them in ParmEditor Windows .

.thanks!

Link to comment
Share on other sites

If you are using the edit parm window the mini menu you refer to is redialy available.

There a several palces, but most genericaly

place a string field

place "ordered menu"

go to the "menu" tab

check "use menu"

and change type to "normal mini"

on the string field check "horizontally joi.." on parameter tab

apply.

To get it to display available groups you will liely want a script in the "menu script" radio tab in the mini menus menu tabs to pull the availible groups and then generate a list of token/labels

Link to comment
Share on other sites

If you are using the edit parm window the mini menu you refer to is redialy available.

There a several palces, but most genericaly

place a string field

place "ordered menu"

go to the "menu" tab

check "use menu"

and change type to "normal mini"

on the string field check "horizontally joi.." on parameter tab

apply.

To get it to display available groups you will liely want a script in the "menu script" radio tab in the mini menus menu tabs to pull the availible groups and then generate a list of token/labels

well .. thank you for your help eyevex, but it was mostly on the ' designing side ' .

anyway , i really appreciate that .

..

so far i was able to script the mini-menu's interaction with the string parameter .

but i'm currently having problems with removing the latest added group in the string parameter ( ! )

illustartion : lets say i have 2 groups 1 and 2 in the string parameter . if add the 3rd and the next action is to remove it ; it fails .

any help or suggestion on this wd be appreciated .. thanks!

maybe there is a shorter way to do this ( ? )

here is the code : ( the getFinalState def is just for printing out actually )

def getFinalState():
    grpStateList = hou.pwd().evalParm( "groups_l" )

    print '- - '*10 + '+ done .'
    print grpStateList

    return grpStateList


def getGroup():
    node = hou.pwd()
    geo = node.geometry()

### "groups_l" refers to string parameter
### "groups_m" refers to mini menu items


### this part to avoid an empty element sometimes appearing in list ..
    grpState = node.evalParm( "groups_l" )
    if grpState == "":
        grpStateList = []
    else:
        grpStateList = grpState.split( ' ' )


### few boolean operation with lists here ..
    grpGeoList = [ group.name() for group in geo.primGroups() ]
    grpRemovable = set( grpGeoList ).intersection( set( grpStateList ) )
#    print 'removable .. >>', grpRemovable
    grpAddable = set( grpGeoList ).union( set( grpStateList ) ) - grpRemovable
#    print 'addable .. >>', grpAddable

    i = 0
    grpNewList = grpStateList
    for group in grpGeoList:
        if node.evalParm( "groups_m" ) == i:
            ## add group to mask ..
            if group in list( grpAddable ):
                if len( grpRemovable ) == 0:
                    grpNewList = []
                    node.setParms( { "groups_l" : group } )
                else:
                    grpNewList.append( group )
                    grpString = ' '.join( grpNewList )
                    node.setParms( { "groups_l" : grpString } )
            ## remove group from mask ..
            if group in list( grpRemovable ):
                grpNewList.remove( group )
                grpString = ' '.join( grpNewList )
                node.setParms( { "groups_l" : grpString } )
        i += 1

    getFinalState()

**

@moderators : i think now ( and i had few doubts before opening this thread here ) is more appropriate to move this in the 'Scripting' section . feel free to do it ..

.cheers

Link to comment
Share on other sites

  • 2 years later...

For myself i found another way. There's a some node inside my otl ("xform" for example) and i want "group" parameter from this "xform" to promote onto a digital asset level:

1. go to "Parameters -> From Node" Tab of Type Properties.

2. find that "xform" inside digital asset and select its "group" parameter.

That's all.

  • Like 2
Link to comment
Share on other sites

  • 5 years later...

Here is the script I created to pre-poulate the groups menu:

# Get the currently selected group type
geometryType = kwargs["node"].parmTuple( "grouptype" )

# Get the value (points, edges, prims, etc)
for tuple in geometryType:
  type = tuple.rawValue()

menu = []
i = 0
# Get the current node
node = kwargs.get( "node", None )

# Select the groups to work with based
# on the selected group type
if node:
  if type == "points" ||:
    groups = node.geometry().pointGroups()
  elif type == "edge":
    groups = node.geometry().edgeGroups()
  elif type == "prims":
    groups = node.geometry().primGroups()
  else:
    return menu
  
  # Iterate through the groups and
  # add each name to the menu
  for group in groups:
    gName = group.name()
    menu.extend( [str(i), gName] )
    i += 1

return menu

 

menu-script.png

  • Like 1
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...