macroScript ExpandSelection category:"Tools" tooltip:"Expand Selection" 
(
------------------------------------
--Expand Selection MacroScript
--Version 1.0 - 6/10/99
--Code by Borislav Petrov
--bobo@email.archlab.tuwien.ac.at
--Idea by Daniel Manahan 
------------------------------------
--Expands both Vertex and Face selection
------------------------------------

global w_node_mod = undefined

work_array = selection as array
if work_array.count == 1 and superclassof work_array[1] == GeometryClass then
(
w_node = work_array[1]
w_node_type = modPanel.getCurrentObject ()
try
(
w_node_mod = modPanel.getModifierIndex w_node w_node_type
)
catch
(
w_node_mod = undefined
)

	
fn convert_vs2fs w_n keep_state w_n_m =
(
if w_node_mod == undefined then
	(
	get_v_sel = getvertselection w_n
	)
	else
	(
	get_v_sel = getvertselection w_n w_n_m
	)
set_face_sel = #()
for i in get_v_sel do
(
for f = 1 to w_n.numfaces do
	(
	face = getface w_n f
	if face.x == i or face.y == i or face.z == i then append set_face_sel f
	)
)--end i loop	
if w_node_mod == undefined then
	(
	setfaceselection w_n set_face_sel keep:keep_state
	)
	else
	(
	setfaceselection w_n w_n_m set_face_sel keep:keep_state
	)

)

fn convert_fs2vs w_n keep_state w_n_m =
(
if w_node_mod == undefined then
	(
	get_f_sel = getfaceselection w_n
	)
	else
	(
	get_f_sel = getfaceselection w_n w_n_m
	)

set_vert_sel = #()
for f in get_f_sel do
(
	face = getface w_n f
	append set_vert_sel face.x 
	append set_vert_sel face.y
	append set_vert_sel face.z 
	)
if w_node_mod == undefined then
	(
	setvertselection w_n set_vert_sel keep:keep_state	
	)
	else
	(
	setvertselection w_n w_n_m set_vert_sel keep:keep_state	
	)
	
)--end fn

if SubObjectLevel == 1 then 
	(
	convert_vs2fs w_node false w_node_mod
	convert_fs2vs w_node true w_node_mod
	)
	
if SubObjectLevel == 3 then 
	(
	convert_fs2vs w_node false w_node_mod
	convert_vs2fs w_node true w_node_mod
	convert_fs2vs w_node false w_node_mod
	)

if w_node_mod != undefined then select w_node
)--end if

)--end script