Why it didn't run?

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 06 June 2008   #1
Why it didn't run?

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
 
 
Old 06 June 2008   #2
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
    

Last edited by zortech : 06 June 2008 at 08:12 AM.
 
Old 06 June 2008   #3
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.
__________________
Love and kisses your cousin Ted.
PS; My thumb hurts...

Last edited by decapitator : 06 June 2008 at 08:43 AM.
 
Old 06 June 2008   #4
Oh```Great!
Thank you "zortech" and "decapitator".
I have solved my problem by you!!
 
Old 06 June 2008   #5
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 02:36 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.