[Closed] Displaying current selection in UI?
Hi, I have a little problem. I’m trying to redo the editable poly interface for myself to get rid of the command panel. I’m making a minimalistic ui that uses all the tools I usually use, and a few workflow improvements on exsisting tools. The problem I’m having is showing the current selection somehow in my ui; how many verts, edges and polygons that are currently selected. I have gotten as far as this(wich is not very far, heh):
c = $.selectedverts.count as[size=2] string[/size]
[size=2][/size]
[size=2]…wich gives me a value of how many verts are selected. I want to put this into my ui somehow in a label or a button and I want it updated whenever the selection changes. Of course the value should also change based on wich subobject I’m currently in.[/size]
[size=2][/size]
[size=2]I’ve been trying like crazy to do this myself but I can’t find out how. I want it shown in the same way the normal Editable poly interface shows it, but I can’t seem to access that to see how it’s done. Any solutions are very appreciated.[/size]
[size=2][/size]
[size=2]CML
[/size]
Hi,
Here is a small example that will help you start.
It updates a label in a rollout floater with the number of selected vertices of the selected mesh.
Hope this helps.
rollout FloaterExample "FloaterExample" width:162 height:98
(
--create a label to show the selected vertices count
label NumVertsLbl "Num Sel Verts : 0" pos:[27,18] width:102 height:22
)
-- create the rollout window and add the rollout
if FloaterExampleFloater != undefined do
(
closerolloutfloater FloaterExampleFloater
)
FloaterExampleFloater = newRolloutFloater "FloaterExample Floater" 200 500
addRollout FloaterExample FloaterExampleFloater
fn UpdateUI =
(
if ($ != undefined and $ != selection) then
(
mesh = snapshotAsMesh $
NumSelVerts = mesh.selectedverts.count as string
FloaterExample.NumVertsLbl.text = "Num Sel Verts : "+NumSelVerts
)
else
(
FloaterExample.NumVertsLbl.text = "Num Sel Verts : 0"
)
)
--Remove any existing callbacks with this ID.
callbacks.removeScripts id:#myselcallback
--Add a new callback function
callbacks.addScript #selectionSetChanged "UpdateUI()" id:#myselcallback
Regards,