[Closed] How to select all all the vertex whose vertex alpha is 50?
hi…everyone.
I fall across a problem:
I set my model’s vertex alpha is 50 in “vertex Properties” panel, and now i need to change them to 20, so how to find the vertex whose alpha is 50? there’re too many models, so it’s diffcult for me to find them manual.
selected = selection as array -- Make array selection
col1 = [0.5,0.5,0.5] --50% alpha
col2 = [0.2,0.2,0.2] --20% alpha
for obj in selected do
(
for i = 1 to (meshop.getNumMapVerts obj -2) do if (meshop.getMapVert obj -2 i) == col1 then meshop.setMapVert obj -2 i col2
update obj
)
Just select and run then code…
Hi akram…
Thanks for your replay:D . It works very well.
And i write this with your help, i write the value (such as:50) in the edittext, then when i click the button “Show Vertex”, all the vertex are selected whoes vaule is 50.
But there’s something wrong in it:
Rollout caption1 "My Tool"
(
button click1 "Show Vertex" width:150 height:25 pos:[10,15]
label lab1 "Vertex Alpha:" width:130 height:25 pos:[10,55]
edittext editx "" fieldWidth:53 pos:[100,53] labelOnTop:false
on click1 pressed do
(
selected = selection as array
col1 = ()
col1 = editx.text
for obj in selected do
(
for n = 1 to (polyop.getNumMapVerts obj) do
(
for i = 1 to (polyop.getNumMapVerts obj -2) do if col1 == (polyop.getMapVert obj -2 i) then select n
)
update obj
)
)
)
newroll = newrolloutfloater "ShowVertex" 180 180
addRollout caption1 newroll
The problem with your code is that you are not converting the text value into a color value and i think it would be better if u apply the value rather than selecting it and applying the value.
Code for selection
(
Rollout caption1 "My Tool"
(
button click1 "Show Vertex" width:150 height:25 pos:[10,15]
label lab1 "Vertex Alpha:" width:130 height:25 pos:[10,55]
edittext editx "" fieldWidth:53 pos:[100,53] labelOnTop:false
on click1 pressed do
(
selected = selection as array
col1 = [1,1,1] * (editx.text as integer)/100
for obj in selected do
(
vertlist = for i = 1 to (polyop.getNumMapVerts obj -2) where col1 == (polyop.getMapVert obj -2 i) collect i
polyop.setVertSelection obj vertlist
)
)
)
newroll = newrolloutfloater "ShowVertex" 180 180
addRollout caption1 newroll
)
Code for changing value.
(
Rollout caption1 "My Tool"
(
button click1 "Change Vertex Alpha" width:150 height:25 pos:[10,15]
-- label lab1 "" width:130 height:25 pos:[10,55]
edittext edit1 "From Vertex Alpha:" labelOnTop:false
edittext edit2 "To Vertex Alpha:" labelOnTop:false
on click1 pressed do
(
selected = selection as array
col1 = [1,1,1] * (edit1.text as integer)/100
col2 = [1,1,1] * (edit2.text as integer)/100
for obj in selected do
(
for i = 1 to (polyop.getNumMapVerts obj -2) where col1 == (polyop.getMapVert obj -2 i) do polyop.setMapVert obj -2 i col2
update obj
)
)
)
newroll = newrolloutfloater "Change Vertex Alpha" 180 180
addRollout caption1 newroll
)
Aha…it’s perfect…
Now i know where i mistake ,Thank you very much…akram. You are thoughful always.