Message 1 of 4
Extract all circular edges from assembly / surfacebody

Not applicable
04-14-2020
03:48 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am working on a routine to extract all circular edges in occurrences in a large assembly.
The routine works fine, but takes for ages to complete (a total of 22.000 edges). gives 30 minutes processing time. Could there be a better way of extracting the circles?
Dim nCount As Long = 0
Dim oCircles As List(Of Circle) = New List(Of Circle)
Using oFile As StreamWriter = My.Computer.FileSystem.OpenTextFileWriter("C:\temp\circles.lst", False, System.Text.Encoding.ASCII)
Dim oAssyDoc As AssemblyDocument = oInvApp.ActiveDocument
Dim oAssyDef As AssemblyComponentDefinition = oAssyDoc.ComponentDefinition
For Each oOcc As ComponentOccurrence In oAssyDef.Occurrences
Dim oPartDef As PartComponentDefinition = oOcc.Definition
For Each oSurfBody As SurfaceBody In oOcc.SurfaceBodies
For Each oEdge As Edge In oSurfBody.ConvexEdges
If oEdge.GeometryType = CurveTypeEnum.kCircleCurve Then
Dim oCircle As Circle = oEdge.Geometry
'If oCircle.Radius > 1 Then
oFile.WriteLine(oCircle.Center.X * 10 & ";" & oCircle.Center.Y * 10 & ";" & oCircle.Center.Z * 10 & ";" & oCircle.Normal.X & ";" & oCircle.Normal.Y & ";" & oCircle.Normal.Z & ";" & oCircle.Radius * 10)
oCircles.Add(oEdge.Geometry)
nCount += 1
'End If
End If
Next
Next
Next
End Using