CGTalk > Software > Autodesk 3ds max > 3dsMax SDK and MaxScript
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 06-03-2008, 03:16 AM   #1
PerfectIdea
New Member
portfolio
Gregory
Berlin, Germany
 
Join Date: Jun 2008
Posts: 2
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.

Code:
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-03-2008, 08:10 AM   #2
zortech
Guest
 
Posts: n/a
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.
Code:
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-03-2008 at 08:12 AM.
 
Old 06-03-2008, 08:39 AM   #3
decapitator
Veteran
portfolio
Jenne van der Meer
Unemployed :(
Zwolle, Netherlands
 
Join Date: Feb 2007
Posts: 84
Send a message via MSN to decapitator
If were on about that i would cut it down even further
Code:
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-03-2008 at 08:43 AM.
 
Old 06-03-2008, 09:30 AM   #4
PerfectIdea
New Member
portfolio
Gregory
Berlin, Germany
 
Join Date: Jun 2008
Posts: 2
Oh```Great!
Thank you "zortech" and "decapitator".
I have solved my problem by you!!
 
Old 06-03-2008, 09:30 AM   #5
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,481
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 06:58 AM.


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