Extract all circular edges from assembly / surfacebody

Extract all circular edges from assembly / surfacebody

Anonymous
Not applicable
554 Views
3 Replies
Message 1 of 4

Extract all circular edges from assembly / surfacebody

Anonymous
Not applicable

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

 

 

0 Likes
555 Views
3 Replies
Replies (3)
Message 2 of 4

WCrihfield
Mentor
Mentor

Placing all of your "Dim" definitions above the first loop ("Using"), then just setting the values of those variables within the loops, should help with processing speed.

I'm, curious though, as to why you need all that data from every circle within a large assembly?

Also curious what the nCount line is for?

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 4

Anonymous
Not applicable

Thanks for your response

 

When compiling in VS, all declarations are automatically moved out of the loops, hence there is no difference where it is defined.

 

I am trying to simplify some geometry export. ie for my export I was trying to see if it is possible only to extract circular edges. It decided to go for an export to IGES, and then extract the circular edges from here.

Not exactly what I wanted, but it does work.

 

 

0 Likes
Message 4 of 4

WCrihfield
Mentor
Mentor

What you're doing looks pretty straight forward and simple, so my only suggestion is to somehow incorporate Multi-threading or Multi-Processing.  I'm not experienced in doing this myself, but I have seen a few others here on this forum who have started using these methods.  It is System level stuff, and can be accessed through iLogic.  The following line starts you into that area of code.

System.Threading

There are many resources online that attampt to teach how to use these methods, if you type "VB.NET System.Threading" or "Visual Basic Threading" into your browser's search engine.

I hope this helps.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes