macroScript DESIE category:"Tools" tooltip:"Dont Ever Select Inivisible Edges" 
(
------------------------------------
--Dont Ever Select Inivisible Edges 
--(DESIE) MacroScript
--Version 1.01 - 6/17/99
--Coded by Borislav Petrov
--bobo@email.archlab.tuwien.ac.at
--for Daniel Manahan 
------------------------------------

--*Go to SubObject/Edge Level and press the DESIE button - 
--this will turn the script on. You will be unable to 
--select Invisible edges. 

--*Note that each Modifiers and the Editable Mesh are handled
--separately - you need to press the button once you get into
--a SO level of a new modifier. The last modifier and the
--base EditMesh will remember their DESIE state until turned off.

--*To turn DESIE off for ALL modifiers, just go into Object
--Mode or any other SubObject mode than Edge and press the DESIE button.



w_node = $

fn deselect_invisible work_node=
(
if SubObjectLevel ==2 then
(
w_node_type = modPanel.getCurrentObject ()
try
(
w_node_mod = modPanel.getModifierIndex work_node w_node_type
)
catch
(
w_node_mod = undefined
)

if w_node_mod == undefined then
	(
	edge_sel_array = getedgeselection work_node
	)
	else
	(
	edge_sel_array = getedgeselection work_node w_node_mod
	)


new_edge_selection = #()
for i in edge_sel_array do
	(
	edge_index_calc = (i/3.0)-(i/3)
	edge_index = 1
	if edge_index_calc > 0.6 then edge_index = 2
	if edge_index_calc == 0 then edge_index = 3
	
	if (getedgevis work_node (ceil(i/3.0)) edge_index)== true then 
		(
		append new_edge_selection i
		)
	)

if w_node_mod == undefined then
	(
	setedgeselection work_node new_edge_selection
	pushprompt "EMesh Purged from Invisible Edges"	
	)
	else
	(
	setedgeselection work_node w_node_mod new_edge_selection
	pushprompt "Modifier Purged from Invisible Edges"
	)	
)--end if
)--end function


deleteAllChangeHandlers id:#dasie_select


if SubObjectLevel ==2 then
(

w_node_type = modPanel.getCurrentObject ()
try
(
w_node_mod = modPanel.getModifierIndex w_node w_node_type
when select w_node.modifiers[w_node_mod] changes  id:#dasie_select do 
	(
	deselect_invisible w_node
	)
)
catch
(
when select w_node changes HandleAt:#RedrawViews id:#dasie_select do 
	(
	deselect_invisible w_node
	)
)
)

)--end script
