Notifications
Clear all

[Closed] togglesmooth script affect only selected?

hi, in addition to my other thread, i have another question for the same script, but i created this other thread, since the subject is another.

i edited a script that i found available here, to fit my needs, it toggles smooth on and off, but now it toggles for all objects in the scene, and i wanted it to affect only selected objects. how to do so?

heres the script:

macroScript Toggle category:"Rafael"
(
	
try(destroyDialog ToggleSmooth)catch()
	
global Toggle_Smooth
global MS_array = #()
global TS_array = #()

rollout ToggleSmooth "Toggle Smooth on/off" width:150 height:40
(

CheckButton TSmooth "Smooth" highlightColor:green height:20 align:#left offset:[-5,0] across:2
	
fn TSSelectON =
		(
		start = timeStamp()
		for o in geometry do if  superclassof  o == geometryClass do 
			(
			for mod in o.modifiers where classof mod == turbosmooth do
				(
				if o.turbosmooth.enabled == false then
					(
					o.turboSmooth.enabled = true
					)
				append TS_array o.name 
				)
			for mod in o.modifiers where classof mod == meshsmooth do
				(
				if o.meshsmooth.enabled == false then
					(
					o.meshsmooth.enabled = true
					)
				append MS_array o.name 
				)
			)
		end = timeStamp()	
		format "Processing took % seconds
" ((end - start) / 1000.0)
		)	

fn TSSelectOFF =
		(
		start = timeStamp()
		for o in geometry do if superclassof  o == geometryClass do 
				(
				for mod in o.modifiers where classof mod == turbosmooth do
					(
					if o.turbosmooth.enabled == true then
						(
						o.turboSmooth.enabled = false
						)
					append TS_array o.name
					)
				for mod in o.modifiers where classof mod == meshsmooth do
					(
					if o.meshsmooth.enabled == true then
						(
						o.meshsmooth.enabled = false
						)
					append MS_array o.name
					)
				)
			end = timeStamp()	
			format "Processing took % seconds
" ((end - start) / 1000.0)
		)

on TSmooth changed state do
		(
			if state == on then
				(
				   TSSelectON()
				)
				else
				(
					TSSelectOFF()
				)
		)
		
on ToggleSmooth close do
	(
		TS_array = #()
		MS_array = #()
	)

)

createdialog ToggleSmooth width:220 height:30

)

thanks in advance

2 Replies

just replace geometry with selection in the two instances that it is used in the script (for o in geometry do…)

1 Reply
(@fael097)
Joined: 11 months ago

Posts: 0

perfect, thanks!