Announcement

Collapse
No announcement yet.

How do I remove meshsmooth from a lot of objects using script ?

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

  • How do I remove meshsmooth from a lot of objects using script ?

    ...and possibly replace all the objects with a turbosmooth modifier.

    I've tried this script from scriptspot but it doesn't work.

    Code:
    [B]
    objArr = #[COLOR=#66CC66]([/COLOR][COLOR=#66CC66])[/COLOR][COLOR=#B1B100]for[/COLOR] o in [COLOR=#000066]objects[/COLOR] where o.modifiers.count [COLOR=#66CC66]![/COLOR]= 0 [COLOR=#B1B100]do[/COLOR][COLOR=#66CC66]([/COLOR]	[COLOR=#B1B100]for[/COLOR] m in o.modifiers where [COLOR=#000066]classof[/COLOR] m == TurboSmooth [COLOR=#B1B100]do[/COLOR] append objArr o[COLOR=#66CC66])[/COLOR][COLOR=#B1B100]for[/COLOR] o in objArr [COLOR=#B1B100]do[/COLOR] [COLOR=#66CC66]([/COLOR]	[COLOR=#B1B100]for[/COLOR] m = o.modifiers.count to 1 by -1 where [COLOR=#000066]classof[/COLOR] o.modifiers[COLOR=#66CC66][[/COLOR]m[COLOR=#66CC66]][/COLOR] == meshsmooth [COLOR=#B1B100]do[/COLOR]	[COLOR=#66CC66]([/COLOR]		deleteModifier o m	[COLOR=#66CC66])[/COLOR]	addmodifier o [COLOR=#66CC66]([/COLOR]TurboSmooth[COLOR=#66CC66]([/COLOR][COLOR=#66CC66])[/COLOR][COLOR=#66CC66]) [/COLOR][/B][B]
    [COLOR=#66CC66])[/COLOR][/B]
    Regards

    Steve

    My Portfolio

  • #2
    Code:
    global tarObj = #()
    global objwithMS = #()
    global objwithtrb = #()
    
    rollout general "Target Objects"
    (
    	radiobuttons genrad1 labels:#("All Objects", "Selected Objects")
    	label genlb1 "Script will not work on objects whose" 
    	label genlb2 "Smooth modifier names are changed"
    
    	on general open do
    	(
    		tarObj = #()
    		tarObj = $* as array
    	)
    	
    	on genrad1 changed state do 
    	(
    		if genrad1.state == 1 then 
    		(
    			tarObj = #()
    			tarObj = $* as array
    		)
    		else if genrad1.state == 2 then
    		(
    			tarObj = #()
    			tarObj = selection as array
    		)
    		
    	)	
    )
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    fn msobj = 
    (
    	objwithMS = for i in tarObj collect if 
    	(superclassof i == GeometryClass and classof i != Targetobject and classof i != BoneGeometry and classof i != Biped_Object and i.modifiers[#meshsmooth] != undefined)
    	then i else dontcollect
    )
    
    fn trbobj = 
    (
    	objwithTRB = for i in tarObj collect if 
    	(superclassof i == GeometryClass and classof i != Targetobject and classof i != BoneGeometry and classof i != Biped_Object and i.modifiers[#turbosmooth] != undefined)
    	then i else dontcollect
    )
    
    
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    
    rollout mssmooth "MeshSmooth Options"
    (
    	button msbtn1 "OFF" width:150 pos:[15,5]
    	button msbtn2 "ON" width:150 pos:[15,30]
    	button msbtn3 "OFF in Viewport" width:150 pos:[15,55]
    	spinner msspn1 "Iterations:" range:[0,10,1] type:#integer pos:[39,85]
    	label mslb1 "Render Values:" align:#left pos:[16,102]
    	checkbox mschk1 "" pos:[15,120]
    	spinner msspn2 "Iterations:" range:[0,10,0] type:#integer pos:[39,120] enabled:false
    	checkbox mschk2 " Isoline Display" pos:[15,140]
    	button msbtn4 "Delete" width:150 pos:[15,160]
    	 
    	
    
    	on msbtn1 pressed do
    	(
    		
    		msobj()
    		for i in objwithMS do
    		(
    		(i.modifiers[#meshsmooth].enabled = false)
    		)	
    	)
    
    	on msbtn2 pressed do
    	(
    		msobj()
    		for i in objwithMS do
    		(
    			i.modifiers[#meshsmooth].enabledinviews = true
    			i.modifiers[#meshsmooth].enabled = true
    		)
    	)
    	
    	on msbtn3 pressed do
    	(
    		msobj()
    		for i in objwithMS do
    		(
    			i.modifiers[#meshsmooth].enabled = true
    			i.modifiers[#meshsmooth].enabledinviews = false
    		)
    	)
    	
    	on msspn1 changed val do
    	(
    		msobj()
    		for i in objwithMS do
    		(
    		i.modifiers[#MeshSmooth].iterations = msspn1.value
    		)
    	)
    	
    	on mschk1 changed theState do
    	(
    		if mschk1.state == true then
    		(
    			msspn2.enabled = true
    			msobj()
    			for i in objwithMS do
    			(
    				i.modifiers[#MeshSmooth].useRenderIterations = on
    			)
    		)	
    		else
    		(
    			msspn2.enabled = false
    			msobj()
    			for i in objwithMS do
    			(
    				i.modifiers[#MeshSmooth].useRenderIterations = off
    			)
    		)
    	)
    	
    	on msspn2 changed theState do
    	(
    		if mschk1.state == true then
    		(
    			msobj()
    			for i in objwithMS do
    			(
    				i.modifiers[#MeshSmooth].RenderIterations = msspn2.value
    			)
    		)	
    	)
    	
    	on mschk2 changed theState do
    	(
    		msobj()
    		if mschk2.state == true then
    		(
    			for i in objwithMS do
    			(
    				i.modifiers[#MeshSmooth].isolineDisplay = on
    			)
    		)
    		else if mschk2.state == false then
    		(
    			for i in objwithMS do
    			(
    				i.modifiers[#MeshSmooth].isolineDisplay = off
    			)
    		)	
    	)
    	
    	on msbtn4 pressed do
    	(
    		
    		msobj()
    		for i in objwithMS do
    		(
    			deleteModifier i i.modifiers[#MeshSmooth]
    		)
    
    	)
    	
    
    )
    
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    rollout trbsmooth "TurboSmooth Options"
    (
    	button trbbtn1 "OFF" width:150 pos:[15,5]
    	button trbbtn2 "ON" width:150 pos:[15,30]
    	button trbbtn3 "OFF in Viewport" width:150 pos:[15,55]
    	spinner trbspn1 "Iterations:" range:[0,10,1] type:#integer pos:[39,85]
    	label trblb1 "Render Values:" align:#left pos:[16,102]
    	checkbox trbchk1 "" pos:[15,120]
    	spinner trbspn2 "Iterations:" range:[0,10,0] type:#integer pos:[39,120] enabled:false
    	checkbox trbchk2 " Isoline Display" pos:[15,140]
    	button trbbtn4 "Delete" width:150 pos:[15,160]
    
    	on trbbtn1 pressed do
    		(
    			trbobj()
    			for i in objwithtrb do
    			(
    			(i.modifiers[#turbosmooth].enabled = false)
    			)	
    		)
    	
    		on trbbtn2 pressed do
    		(
    			trbobj()
    			for i in objwithtrb do
    			(
    				i.modifiers[#turbosmooth].enabledinviews = true
    				i.modifiers[#turbosmooth].enabled = true
    			)
    		)
    		
    		on trbbtn3 pressed do
    		(
    			trbobj()
    			for i in objwithtrb do
    			(
    				i.modifiers[#turbosmooth].enabled = true
    				i.modifiers[#turbosmooth].enabledinviews = false
    			)
    		)
    		
    		on trbspn1 changed val do
    		(
    			trbobj()
    			for i in objwithtrb do
    			(
    			i.modifiers[#turboSmooth].iterations = trbspn1.value
    			)
    		)
    		
    		on trbchk1 changed theState do
    		(
    			if trbchk1.state == true then
    			(
    				trbspn2.enabled = true
    				trbobj()
    				for i in objwithtrb do
    				(
    					i.modifiers[#turboSmooth].useRenderIterations = on
    				)
    			)	
    			else
    			(
    				trbspn2.enabled = false
    				trbobj()
    				for i in objwithtrb do
    				(
    					i.modifiers[#turboSmooth].useRenderIterations = off
    				)
    			)
    		)
    		
    		on trbspn2 changed theState do
    		(
    			if trbchk1.state == true then
    			(
    				trbobj()
    				for i in objwithtrb do
    				(
    					i.modifiers[#turboSmooth].RenderIterations = trbspn2.value
    				)
    			)	
    		)
    		
    		on trbchk2 changed theState do
    		(
    			trbobj()
    			if trbchk2.state == true then
    			(
    				for i in objwithtrb do
    				(
    					i.modifiers[#turboSmooth].isolineDisplay = on
    				)
    			)
    			else if trbchk2.state == false then
    			(
    				for i in objwithtrb do
    				(
    					i.modifiers[#turboSmooth].isolineDisplay = off
    				)
    			)	
    		)
    		
    		on trbbtn4 pressed do
    		(
    			
    			trbobj()
    			for i in objwithtrb do
    			(
    				deleteModifier i i.modifiers[#turboSmooth]
    			)
    	
    		)
    
    )
    
    rollout abt "About" rolledUp:true
    (
    label ablb1 "Developed by Vikram Shingrani"	
    hyperLink gmail "email : [email]vshingrani@gmail.com[/email]" color:(color 0 0 255) address:"mailto:vshingrani@gmail.com" align:#center
    )
    
    
    
    
      
    
    
    myfloater = (newRolloutFloater "Smooth Manager" 195 552)
    addRollout general myfloater
    addRollout mssmooth myfloater
    addRollout trbsmooth myfloater
    addRollout abt myfloater
    CGI - Freelancer - Available for work

    www.dariuszmakowski.com - come and look

    Comment


    • #3
      Wicked ! You are da man !
      Regards

      Steve

      My Portfolio

      Comment


      • #4
        Happy to help
        CGI - Freelancer - Available for work

        www.dariuszmakowski.com - come and look

        Comment


        • #5
          zorb is the key for this stuff

          Comment

          Working...
          X