# top edge selection problem

hi
pls Please understand the greedy things

i am seeking top edge selection ~~
this area is difficult to me still
example : gable roof top edge select
this is my code , ~~ that is my limit
pls help me~~

for o in selection where isKindOf o Editable_Poly or isKindOf o Editable_Mesh do
(
topedge = #{}

gfc = polyOp.getNumEdges o
for f = 1 to o.getNumedges do
(
if (gfc o f).z == o.max.z do append topedge f

)
o.selectededges = topedge

polyop.setedgeSelection o topedge

## Comment viewing options

### .

```(
local tolerance = 0.001

fn getMeshEdgeVerts obj edgeIndex =
(
local faceVerts = getFace obj (((edgeIndex = edgeIndex-1)/3)+1)

case (mod edgeIndex 3) of
(
0: [ faceVerts[1], faceVerts[2] ]
1: [ faceVerts[2], faceVerts[3] ]
2: [ faceVerts[3], faceVerts[1] ]
)

)

for obj in selection do (

maxZ = obj.max.z
topEdges = #{}

case classOf obj of
(

Editable_Poly :
(

for i=1 to polyop.getNumEdges obj do (

ev = polyop.getEdgeVerts obj i

v1 = abs (maxZ - (polyop.getVert obj ev[1]).z) < tolerance
v2 = abs (maxZ - (polyop.getVert obj ev[2]).z) < tolerance

if v1 and v2 do append topEdges i

)

polyop.setEdgeSelection obj topEdges

)

Editable_Mesh :
(
for i=1 to obj.edges.count do (

edgeIndex = 1 + (mod (i-1) 3)
faceIndex = ((i-1)/3)+1

if not getEdgeVis obj faceindex edgeIndex do continue -- skip invisible edges

ev = getMeshEdgeVerts obj i

v1 = abs (maxZ - (getVert obj ev[1]).z) < tolerance
v2 = abs (maxZ - (getVert obj ev[2]).z) < tolerance

if v1 and v2 do append topEdges i

)

setEdgeSelection obj topEdges

)

)

)

redrawViews()
)```

### thank you for good code~~

thank you good coding and your effort realy ~~