ScriptSpot home

Forum topic · Scripts Wanted

Select Hard Edges(the green ones)

By R · 2019-11-13

Downloads
Description

Hello guys,

I need to select Hard Edges.

I saw a similar post selecting hard edges defining a minimum and maximum angle between faces but this is not what I need.

Imagine you have a 32 segment sphere converted to Editable Poly and you randomly declare 2 edges ¨Hard¨, using the Hard button on the Edit Edges rollup. You can see those edges in green if you click on Display Hard Edges, but you wont be able to automatically select them either by angle nor by change of the smoothing groups.

If there´s a way to select those green edges, that would be great.

Thanks.

Comments (7)
miauu

.


macroscript macro_SelectHardEdges
category:"miauu"
tooltip:"Select Hard Edges"
buttonText:"Select Hard Edges"
(
	on execute do
	(
		if selection.count == 1 do
		(
			if classOf (curO = selection[1]) == editable_poly do
			(
				subobjectlevel = 2
				curO.selectHardEdges()
			)
		)
	)
)
Reply to miauu
fzxj520

How to select the edge with Crease value greater than or equal to 0.5 ?

Reply to fzxj520
miauu

(
	creaseVal = 0.5
	poGetEDataValue = polyop.getEDataValue
	if classof (obj = selection[1]) == Editable_Poly do
	(
		
		numEdges = polyop.getNumEdges obj
		edgToSelBA = #{}
		for i = 1 to numEdges where (poGetEDataValue obj 2 i) >= creaseVal do edgToSelBA += #{i}
		
		max modify mode
		subobjectlevel = 2
		polyop.setEdgeSelection obj edgToSelBA
		redrawViews()
	)
)
Reply to miauu
fzxj520

Thank you very much, it's great!
Can you make it work for Edit Poly Modifier too?

I tried to replace the corresponding Edit_Poly code, but I couldn't find it in MAXScript Help.

My modified script ‘ Quick Set Edge crease ’
( obj = modPanel.getCurrentObject() if obj != undefined then
(
case (classof obj) of
(
Edit_Poly:
( obj.setOperation 86 ; obj.dataChannel = 1 ; obj.dataValue = 1 ; obj.Commit ())
Editable_Poly:
( obj.setEdgeData 1 1 )
)
)
)

Reply to fzxj520
miauu




(
	creaseVal = 0.5
	poGetEDataValue = polyop.getEDataValue
	obj = modPanel.getCurrentObject()
	selO = selection[1]
	
	case classOf obj of
	(
		Editable_Poly:
		(
			numEdges = polyop.getNumEdges obj
			edgToSelBA = #{}
			for i = 1 to numEdges where (poGetEDataValue obj 2 i) >= creaseVal do edgToSelBA += #{i}	
			subobjectlevel = 2
			polyop.setEdgeSelection obj edgToSelBA
		)
		Edit_Poly:
		(
			numEdges = obj.getNumEdges()
			edgToSelBA = #{}
			for i = 1 to numEdges where (poGetEDataValue selO 2 i) >= creaseVal do edgToSelBA += #{i}	
			subobjectlevel = 2
			obj.SetSelection #Edge #{}
			obj.Select #Edge edgToSelBA
		)		
	)
	redrawViews()
)