Notifications
Clear all
[Closed] Why it didn't run?
Jun 03, 2008 4:16 am
Hi, i write the script what to select nomaterials objs, but when I tried to run the script, it functioned directly without clicking the button, i didn’t know why.
rollout selectnomat "UnmaterialsObj"
(
button click1 "check"
on click1 pressed do
(
fn selectUnMaterialObj =
(
clearSelection()
num=0
for obj in geometry do if obj.material==undefined do (num+=1;selectMore obj)
pushPrompt (num as string+" objects have no material")
)
selectUnMaterialObj()
)
)
createdialog selectnomat
3 Replies
Jun 03, 2008 4:16 am
Works for me. Though your code structure could be optimized. It doesn’t make sense to put a function within the on button pressed event, as you can only call it in the scope of the on button pressed event.
rollout selectnomat "UnmaterialsObj"
(
button click1 "check"
fn selectUnMaterialObj =
(
clearSelection()
num=0
for obj in geometry where obj.material==undefined do (num+=1;selectMore obj)
pushPrompt (num as string+" objects have no material")
)
on click1 pressed do
(
selectUnMaterialObj()
)
)
createdialog selectnomat
Jun 03, 2008 4:16 am
If were on about that i would cut it down even further
rollout selectnomat "UnmaterialsObj"
(
button click1 "Check"
on click1 pressed do
(
select (for obj in geometry where obj.material == undefined collect obj)
pushPrompt ((getCurrentSelection()).count string+" objects have no material")
)
)
createdialog selectnomat
first collect all then select all at once (quicker/less UI flickering?) and remove the stupid counting. And not a seperate function as zortech mentioned.
Jun 03, 2008 4:16 am
Oh“`Great!
Thank you “zortech” and “decapitator”.:applause:
I have solved my problem by you!!