group object rescale

hi this is walid script
thatnk you for good script

i want mutiple object regardelss of group or non group object

macroScript ScaleTo category:"Walid" tooltip:"Scale To 1.0"
(
undo on
(
global xlength;

global ylength;

global zlength;

global target;

global ratio;

rollout unnamedRollout "Scale To v1.0" width:162 height:199
(
radiobuttons rdo2 "Reference" pos:[5,4] width:84 height:62 labels:#("X Coordinate", "Y Coordinate", "Z Coordinate")
label lbl2 "Scale To" pos:[5,72] width:44 height:19
spinner spn1 "" pos:[50,72] width:69 height:16 range:[0,1e+006,0]
label lbl3 "cm" pos:[130,72] width:20 height:19
checkbox chk1 "Reset Xform" pos:[5,104] width:131 height:26
button btn1 "Apply" pos:[34,141] width:99 height:29
label lbl7 "Developed By Walid Abou Ali" pos:[7,179] width:144 height:26

on btn1 pressed do
(
units.displaytype = #Metric ;
units.MetricType = #Centimeters;

if $selection.count ==0 then
(

messagebox "no object selected";
)
else if $selection.count > 1 then
(
messagebox "you can only select one object";

)
else
(

xlength=$.max.x-$.min.x;
ylength=$.max.y-$.min.y;
zlength=$.max.z-$.min.z;
target=spn1.value;

if rdo2.state==1 then
(

ratio=target/xlength;

)
else if rdo2.state==2 then
(

ratio=target/ylength;

)
else if rdo2.state==3 then
(

ratio=target/zlength;

)

scale $ [ratio,ratio,ratio];

if chk1.state then
(
resetxform $;
)

)

)
)

createdialog unnamedRollout
)
)

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
miauu's picture

.

-- macroScript ScaleTo category:"Walid" tooltip:"Scale To 1.0"
(
	rollout unnamedRollout "Scale To v1.1" width:162 height:199
	(
		local xlength
		local ylength
		local zlength
		local target
		local ratio	
 
		radiobuttons rdo2 "Reference" pos:[5,4] width:84 height:62 labels:#("X Coordinate", "Y Coordinate", "Z Coordinate")
		label lbl2 "Scale To" pos:[5,72] width:44 height:19
		spinner spn1 "" pos:[50,72] width:69 height:16 range:[0,1e+006,0]
		label lbl3 "cm" pos:[130,72] width:20 height:19
		checkbox chk1 "Reset Xform" pos:[5,104] width:131 height:26
		button btn1 "Apply" pos:[34,141] width:99 height:29
		label lbl7 "Developed By Walid Abou Ali" pos:[7,179] width:144 height:26		
 
		on btn1 pressed do
		(
			units.displaytype = #Metric ;
			units.MetricType = #Centimeters;
 
			selObjsArr = selection as array			
 
			if selObjsArr.count != 0 then with undo "Scale Objects" on
			(
				for o in selObjsArr do with redraw off
				(
					xlength = o.max.x - o.min.x
					ylength = o.max.y - o.min.y
					zlength = o.max.z - o.min.z
					target = spn1.value
 
					if rdo2.state == 1 then
					(	
						ratio = target / xlength
					)
					else if rdo2.state == 2 then
					(
						ratio = target / ylength
					)
					else if rdo2.state == 3 then
					(
						ratio = target / zlength
					)
 
					scale o [ratio,ratio,ratio]
 
					if chk1.state then
					(
						resetxform o
					)
				)
			)
			else
				messagebox "Plsease, select some objects" title:"Invalid Selection"			
		)
	)
	createdialog unnamedRollout 
)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.