PDA

View Full Version : Why it didn't run?


PerfectIdea
06-03-2008, 03: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

zortech
06-03-2008, 08:10 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

decapitator
06-03-2008, 08:39 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.

PerfectIdea
06-03-2008, 09:30 AM
Oh```Great!
Thank you "zortech" and "decapitator".:applause:
I have solved my problem by you!!

CGTalk Moderation
06-03-2008, 09:30 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.