@Michael.Navara Thank you very much for fast replay.
Its a solution for my question but i'm having some problems integrate it in my code
Here is the code. I would like to project 2 edges from that collection, edges ar located left and right in geometric space from my oEdge (imagine a pyramid with 5faces and at the tip is my collection of edges, one of the edges is oEdge. I need the left and right edges of oEdge). The collection can have from 3 to 6 maybe 7 edges.
I have a case (Case V1) were oEdge has index 3 and Total no of edges in the collection is 4, so i-1 and i+1 should be correct. Another case (Case V3) were oEdge has index 1 and Total no of edges in the collection is 4, so n and 2 should be correct. I don't know the logic regarding order indexing in a collection. I thought is based on a clockwise direction or something similar, but it has no logic.
i would like a solution to better identify the 2 edges I need. Tx.
Sub Main()
Dim oApp = ThisApplication
Dim part As PartDocument = ThisDoc.Document
Dim partDef = part.ComponentDefinition
Dim bodies = partDef.SurfaceBodies
For Each body As SurfaceBody In bodies
Dim edges = body.Edges
For Each oEdge As Edge In edges
Dim length = oApp.MeasureTools.GetMinimumDistance(oEdge.StartVertex, oEdge.StopVertex)
' MessageBox.Show("Message: " & length, "Title")
Dim wp As WorkPlane
Dim oWkPoint As WorkPoint
oWkPoint = part.ComponentDefinition.WorkPoints.AddFixed(oEdge.PointOnEdge, Construction= False)
wp = part.ComponentDefinition.WorkPlanes.AddByNormalToCurve(oEdge, oWkPoint, Construction= False)
Dim oSketch As Sketch
oSketch = partDef.Sketches.AddWithOrientation(wp, oEdge, True, True, oWkPoint )
Dim n As Integer
n = oEdge.StartVertex.Edges.Count
MessageBox.Show("Message: " & n, "Total Edges")
Dim oEdges As edges = oEdge.StartVertex.Edges
Dim sEntity1 As SketchLine
Dim sEntity2 As SketchLine
Dim i As Integer = 0
For Each vertexEdge As Edge In oEdges
i += 1
'Case V1
If vertexEdge Is oEdge And i<n And i>1 Then
MessageBox.Show("Message: " & i, "oEdge V1")
sEntity1 = oSketch.AddByProjectingEntity(oEdge.StartVertex.Edges.Item(i - 1))
sEntity2 = oSketch.AddByProjectingEntity(oEdge.StartVertex.Edges.Item(i+1))
'Case V2
ElseIf vertexEdge Is oEdge And i=n Then
MessageBox.Show("Message: " & i, "oEdge V2")
sEntity1 = oSketch.AddByProjectingEntity(oEdge.StartVertex.Edges.Item(n - 1))
sEntity2 = oSketch.AddByProjectingEntity(oEdge.StartVertex.Edges.Item(1))
'Case V3
ElseIf vertexEdge Is oEdge And i=1 Then
MessageBox.Show("Message: " & i, "oEdge V3")
sEntity1 = oSketch.AddByProjectingEntity(oEdge.StartVertex.Edges.Item(n))
sEntity2 = oSketch.AddByProjectingEntity(oEdge.StartVertex.Edges.Item(2))
End If
Next
sEntity1.DisabledActionTypes = True
sEntity2.DisabledActionTypes = True
sEntity1.Construction = True
sEntity2.Construction = True
Dim center As SketchPoint
center = oSketch.AddByProjectingEntity(oWkPoint)
Dim profileLine1 As SketchLine
profileLine1 = oSketch.SketchLines.AddByTwoPoints(center, sEntity1.Geometry.MidPoint)
Dim profileLine2 As SketchLine
profileLine2 = oSketch.SketchLines.AddByTwoPoints(center, sEntity2.Geometry.MidPoint)
Dim latime As DimensionConstraint
latime = oSketch.DimensionConstraints.AddTwoPointDistance(center, profileLine1.EndSketchPoint, _
kAlignedDim, ThisApplication.TransientGeometry.CreatePoint2d(1, 0), False)
latime.Parameter.Value = 1
oSketch.GeometricConstraints.AddEqualLength(profileLine1, profileLine2)
oSketch.GeometricConstraints.AddCollinear(sEntity1, profileLine1)
oSketch.GeometricConstraints.AddCollinear(sEntity2, profileLine2)
'Create a Path.
Dim oPath As Path
oPath = partDef.Features.CreatePath(profileLine1)
Dim oContourFlangeFeatures As ContourFlangeFeatures
oContourFlangeFeatures = partDef.Features.ContourFlangeFeatures
'Create the flange definition.
Dim cfDef As ContourFlangeDefinition
cfDef = oContourFlangeFeatures.CreateContourFlangeDefinition(oPath)
cfDef.Operation = kNewBodyOperation
Call cfDef.SetDistanceExtent(length, PartFeatureExtentDirectionEnum.kSymmetricExtentDirection)
Dim oCF As ContourFlangeFeature
oCF = oContourFlangeFeatures.Add(cfDef)
Next
Next
End Sub