Announcement

Collapse
No announcement yet.

Maxscript question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Maxscript question

    Heya

    I cant figure it out. It should work but it dont :/

    Trying to create script for selecting objects/or all in scene and then applying modifiers.
    Can any1 have a look please?

    Code:
    global tarGeo = #()
    
    
    rollout JB_Geometry "Geometry" width:328 height:246
    (
    	button btn_TS "Turbo Smooth" pos:[8,112] width:144 height:24
    	radiobuttons rdo_sel_geo "Geometry selection mode     " pos:[8,8] width:224 height:30 enabled:true labels:#("All Objects", "Selected Objects") default:2 columns:2
    
    	
    	
    	on JB_Geometry open do
    	(
    		tarGeo = #()
    		tarGeo = $* as array
    	)
    	
    	on rdo_sel_geo changed state do
    	(
    		if rdo_sel_geo.state == 1 then 
    		(
    			tarGeo = #()
    			tarGeo = $* as array
    		)
    		else if rdo_sel_geo.state == 2 then
    		(
    			tarGeo = #()
    			tarGeo = selection as array
    		)
    		
    	)
    	
    	
    fn tarGeoSel = 
    	(
    		selGeo = for i in tarGeo collect if 
    		(superclassof i == GeometryClass)
    		then i else dontcollect
    	)
    	
    	on btn_TS pressed do
    		(
    			tarGeoSel()
    			for i in selGeo do
    			(
    			addmodifier i (TurboSmooth ())
    			i.modifiers[#TurboSmooth].Iterations = 1
    			)
    		)
    )
    CGI - Freelancer - Available for work

    www.dariuszmakowski.com - come and look

  • #2
    Hi Dariusz, try this:

    Code:
    global tarGeo = #()
    
    
    try(destroyDialog JB_Geometry)
    catch()
    
    rollout JB_Geometry "Geometry" width:328 height:246
    (
    	button btn_TS "Turbo Smooth" pos:[8,112] width:144 height:24
    	radiobuttons rdo_sel_geo "Geometry selection mode     " pos:[8,8] width:224 height:30 enabled:true labels:#("All Objects", "Selected Objects") default:2 columns:2
    
    	
    	
    	on JB_Geometry open do
    	(
    		tarGeo = #()
    		tarGeo = selection as array
    	)
    	
    	on rdo_sel_geo changed state do
    	(
    		if rdo_sel_geo.state == 1 then 
    		(
    			tarGeo = #()
    			tarGeo = objects as array
    		)
    		else if rdo_sel_geo.state == 2 then
    		(
    			tarGeo = #()
    			tarGeo = selection as array
    		)
    		
    	)
    	
    	
    	fn tarGeoSel = 
    	(
    		selGeo = for i in tarGeo collect if 
    		(superclassof i == GeometryClass)
    		then i else dontcollect
    	)
    	
    	on btn_TS pressed do
    		(
    			selGeo = tarGeoSel()
    			for i in selGeo do
    			(
    			addmodifier i (TurboSmooth ())
    			i.modifiers[#TurboSmooth].Iterations = 1
    			)
    		)
    )
    
    createDialog JB_Geometry
    - Changed default action to selection based to match radio button.
    - "objects as array" instead of $*, bit cleaner.
    - "selGeo = tarGeoSel()" instead of "tarGeoSel()", it was not defined before and wasn't captured in a variable later on.
    - Closes old rollout. Opens new.
    Rens Heeren
    Generalist
    WEBSITE - IMDB - LINKEDIN - OSL SHADERS

    Comment


    • #3
      Heya

      Thanks! That did sort off work :- )

      The only problem I have now is that once I set it to run on all objects, then back to selected, it still remember the list from all objects. Is there a way to reset it out between clicks so that I can just go all/sel/all/sell or I need to keep restarting the script?

      Ps. you know I'll just circle back to basic version of my script without the option of all/selected objects.

      Regards

      Dariusz
      Last edited by Dariusz Makowski (Dadal); 04-03-2015, 11:00 AM.
      CGI - Freelancer - Available for work

      www.dariuszmakowski.com - come and look

      Comment

      Working...
      X