-----------------------------------
--RESIZE PRIMITIVES RCMENU
--Version 0.1
--Started:01/20/2000
--Edited: 01/20/2000
--Borislav Petrov
--http://gfxcentral.com/bobo
-----------------------------------
--Based on a GREAT idea by John Versluis
-----------------------------------
--To install:
--*Copy to \Scripts\Startup\ 
--*Restart MAX
--or
--*Just evaliate for a test drive
-----------------------------------
--To use:
--*Select a Primitive object (modified or not)
--*Right-click
--*Select Resize command from menu
--*Pick a target point to specify the new size
--*Use Snap if needed.
-----------------------------------


RcMenu ResizePrimitives
(
fn flt_cyl = ((selection.count == 1) and (classof selection[1].baseobject == Cylinder))

fn flt_sphere = 
(
return_value = false
if selection.count == 1 then
(
test_class = classof selection[1].baseobject
	if test_class == Sphere or test_class == GeoSphere or test_class == Teapot then return_value = true
)
return_value
)

fn flt_size = 
(
return_value = false
if selection.count == 1 then
(
test_class = classof selection[1].baseobject
	if test_class == Pyramid or test_class == Plane or test_class == Box then return_value = true
)
return_value
)

fn flt_cone = 
(
return_value = false
if selection.count == 1 then
(
test_class = classof selection[1].baseobject
	if test_class  == Cone or test_class == Tube or test_class == Torus then return_value = true
)
return_value
)

fn flt_height = 
(
return_value = false
if selection.count == 1 then
(
test_class = classof selection[1].baseobject
if test_class == Cone or test_class == Cylinder or test_class == Tube or test_class == Pyramid or test_class == Box then return_value = true
)
return_value 
)

MenuItem mi_resize_cyl_radius "Resize Radius" filter:flt_cyl
MenuItem mi_resize_sphere_radius "Resize Radius" filter:flt_sphere
MenuItem mi_resize_cone_radius1 "Resize Radius 1" filter:flt_cone
MenuItem mi_resize_cone_radius2 "Resize Radius 2" filter:flt_cone

MenuItem mi_resize_size_width "Resize Local X Size" filter:flt_size
MenuItem mi_resize_size_length "Resize Local Y Size" filter:flt_size

MenuItem mi_resize_cyl_height "Resize Height" filter:flt_height

-------------------
--RADIUS 2D
-------------------
on mi_resize_cyl_radius picked do 
(
work_node = selection[1]
p = pickpoint snap:#3d
if classof p == Point3 then work_node.baseobject.radius = sqrt((work_node.pos.x-p.x)^2 + (work_node.pos.y-p.y)^2 )
)--end on


-------------------
--RADIUS 3D
-------------------
on mi_resize_sphere_radius picked do 
(
work_node = selection[1]
p = pickpoint snap:#3d
if classof p == Point3 then work_node.baseobject.radius = length(work_node.pos-p)
)--end on

-------------------
--RADIUS 1 & 2
-------------------
on mi_resize_cone_radius1 picked do 
(
work_node = selection[1]
p = pickpoint snap:#3d
if classof p == Point3 then work_node.baseobject.radius1 = sqrt((work_node.pos.x-p.x)^2 + (work_node.pos.y-p.y)^2 )
)--end on

on mi_resize_cone_radius2 picked do 
(
work_node = selection[1]
p = pickpoint snap:#3d
center2 = work_node.pos+[0,0,work_node.max.z]
if classof p == Point3 then work_node.baseobject.radius2 = sqrt((work_node.pos.x-p.x)^2 + (work_node.pos.y-p.y)^2 )
)--end on



-------------------
--HEIGHT ALONG Z
-------------------
on mi_resize_cyl_height picked do 
(
work_node = selection[1]
p = pickpoint snap:#3d
if classof p == Point3 then work_node.baseobject.height = (p.z-work_node.pos.z)
)--end on


-------------------
--SIZE WIDTH (X)
-------------------
on mi_resize_size_width picked do 
(
work_node = selection[1]
p = pickpoint snap:#3d
if classof p == Point3 then 
(
		d = dummy pos:p
		in coordsys work_node np = d.pos
		delete d
		work_node.baseobject.width = abs(np.x*2.0)
)
)--end on

-------------------
--SIZE WIDTH (Y)
-------------------
on mi_resize_size_length picked do 
(
work_node = selection[1]
p = pickpoint snap:#3d
if classof p == Point3 then 
	(
	if classof work_node == Pyramid then
		(
		d = dummy pos:p
		in coordsys work_node np = d.pos
		delete d
		work_node.baseobject.depth = abs(np.y*2.0)
		)
		else
		(
		d = dummy pos:p
		in coordsys work_node np = d.pos
		delete d
		work_node.baseobject.length = abs(np.y*2.0)
		)
	)
)--end on


)--end menu

RegisterRightClickMenu ResizePrimitives
