Dynamic UI expose string parameters

   1528   6   2
User Avatar
Member
6 posts
Joined: 8月 2015
Offline
Hi,

I wish I will be clear enough to share my issue with you.

I would like to create from an input a list of unique values and expose the values in the UI to tag them later..

eg. From a point cloud I have some points with a string attribute:

ptnum 0 name aaa
ptnum 1 name b3b
ptnum 2 name aaa
ptnum 3 name c90
ptnum 4 name bbb

I am able to identify the count(4) of unique values ( in this case:aaa, b3b, c90, bbb )
From this point, I thought having the count value in a multiparm block will create automatically 4 labels where I was able to expose the attribute name using the expression: `details("./get","name")`, but I am not able to preview the attribute name..

I tried also detail("./get","name",0) but still without any result.

I would like to create for each unique name a menu and give the opportunity to choose where the attribute will belong ..

any idea how to do that?

where I am doing wrong ?

thanks
maq

Attachments:
dynamicUI_ 2.hipnc (150.7 KB)

User Avatar
Member
900 posts
Joined: 2月 2016
Offline
the first issue I see is that you ask for a detail attribute that doesn't exist.
`name` is a point attribute indeed. So you should use the `points()` function instead, and use as point number the instance number of the multiparm.

To get the instance number of each multiparm you use
kwargs["script_multiparm_index"]
, as documented here. **
https://www.sidefx.com/docs/houdini/hom/locations.html#parameter_callback_scripts [www.sidefx.com]
However this is only available for callbackscripts.

In the past I resorted with python by looping over each multiparm, and set the label with python.






** remember that by default Multiparm block folders start with 1 as first instance. You should manually set it to 0 in the edit parameter options so that you won't get any index errors when trying to access your points
Edited by Andr - 2022年12月24日 06:23:04
User Avatar
Member
900 posts
Joined: 2月 2016
Offline
Andr
the first issue I see is that you ask for a detail attribute that doesn't exist.
`name` is a point attribute indeed. So you should use the `points()` function instead, and use as point number the instance number of the multiparm.

Ah, I was wrong and I see now what you do inside the subnet.
But still, there is an issue here, as you promote the `name` point attrib to detail, then you end up with only the attribute value of the last iteration.

In this scenario, I usually want one single point for each piece or group of points.
And for your specific case, I would also use create a detail attribute array of the unique names.
The graph in the image is not very efficient, just use it for start.
Edited by Andr - 2022年12月24日 06:54:18

Attachments:
1pointperpiece.JPG (82.5 KB)

User Avatar
Member
6 posts
Joined: 8月 2015
Offline
Thanks for the answer!

Yep sorry it wasn't a great way to share my issue ..I knew the issue of showing just the last iteration. I didn't mention thanks for flagging that!
My first issue was related to the interface where even showing just the last iteration I am not able to read the value ..

Anyway going with the array, as you suggested, do you think creating an array with unique values I could promote as a list in the UI?
not sure how to do that..

Unfortunately I am not good using python, I wish to know how to do it ..I mean even in vex for now it's a bit complicated for me

thanks
User Avatar
Member
900 posts
Joined: 2月 2016
Offline
Check the attached file.
The magic happens in the menu parameter, which now uses the following menu-script.
node = kwargs['node'] ## this node
id = kwargs['script_multiparm_index'] ## id of the current multiparm instance
names = node.geometry().attribValue('names') ## get the array of unique names
name = names[id] ## get the name of the curr parm
node.parm('Name'+str(id)).set(name) ## assign name to the label

## build the menu
menu = ['0', 'letters', '1', 'numbers', '2', 'mix']
return menu

Normally you would use a menu script just to build a dynamic menu.
In your case, we still build a static menu, but we exploit the menu script context to do other stuff in python, like dynamically set the label name, thanks to the fact that in the menu script you have access to the kwargs dictionary (so we can ask for the multiparm instance ID)

PERFORMANCE NOTE:
Menu Scripts are very wild parameters: they run and re-run the code many times to update the UI (you can check yourself by inserting a print() statement in the above code and see your console going crazy). I
In fact it's officially recommended to use a very simple code to build a menu-script.

Add that to the fact that we have multiple menu parameters here, and that you are also using a multiparm block folder, which is by a long shot the very least efficient parameter in Houdini, that is going to slow the UI down once you have 10, 20, 30 and more multiparm instances. So expect a not very fluid user experience if you have a complex scene, with many categories and heavy geometry.

Attachments:
dynamicUI_ 2_proposed.hipnc (126.4 KB)

User Avatar
Member
900 posts
Joined: 2月 2016
Offline
A more efficient way could be to use a Python Sop at the very end of the subnet so that:

- network cooks because of a geometry change upstream
- python sop is also triggered to run, and from inside of the subnet it sets the values for the count of instances in the multiparm block folder.
- the latter has a callbackscript which loops over each instance and set the proper label name
Edited by Andr - 2022年12月24日 11:03:06
User Avatar
Member
6 posts
Joined: 8月 2015
Offline
Hi,
your proposed file was like gold for me. Thanks!!

I had the opportunity to check some tutorials using python and I will dig even more in the next months..you basically ruined my xmas holidays

I am still having issues controlling the tag from the menu. I tried to create a group and attribute inside the multipart and with a switch connected with the UI menu, I was hoping to isolate or control the output. Unfortunately I didn't succeed.

I will try to find more resources with python but in the meantime here is the file.

Regarding your "more efficient way" I will try to find a way to get this knowledge. Thank you so much

best
maq

Attachments:
dynamicUI_%202_check.hipnc (161.5 KB)

  • Quick Links