Quantcast
Channel: PTC Community: Message List
Viewing all articles
Browse latest Browse all 11712

Finding central axis of surface using VB API

$
0
0

Hello everyone!

 

 

 

I'm working on a project for automated model comparison and I am currently stuck. I am trying to find the central axis of cylindrical and conic surfaces but my code is not working properly. I would be very grateful if someone can help me solve my issue.

 

 

First things first, I am using wildfire 4.0 and this is my first time coding in VBA so there might be stupid mistakes.

 

 

I am using the following code:

 

_______________________________

 

 

 

               For Each Axis In AllAxis_

 

                    On Error Resume Next

                    For Each axis_surf In Axis.Surf.ListSameSurfaces
                        If Not Err.Number = 0 Then
                            GoTo forend                                                            'This is to prevent the code to crash when the axis has no linked surface
                        End If
                        If axis_surf.ID = surface.ID Then
                            SurfTable_(i).CentralAxis = Axis
                            FoundFlag = True
                            Exit For
                        End If

                    Next

                    'End If
                    If FoundFlag Then
                        FoundCount += 1
                        Sel.CreateModelItemSelection(surface, Nothing).Highlight(2) 'Highlight in white if surface axis is found

                        Exit For
                    End If

forend:


                Next
                If Not FoundFlag Then
                    NotFoundCount += 1
                    Sel.CreateModelItemSelection(surface, Nothing).Highlight(1) 'highlight in red if surface axis is not found
                End If

_______________________________

 

I am testing my code on two different model. On one of them, all the central axis are found as expected and on the second one, a few axis are not found.

 

After comparing the surfaces whose axis was not found with the other one. I noticed they were modeled using the revolve tool and an external sketch while the surfaces that were modeled with internal sketch were not problematic. But, after redefining the problematic surfaces the central axis would still not be detected.

 

Another strange issue is that if I search for the central axis of all the cylindrical and conic surfaces instead of just the one I am interested in, my code will find some axis he did not find previously but there is still some axis missing.

 

 

I would really appreciate if someone can help me with this. I have been stuck on this for a while now.

 

 

Jonas


Viewing all articles
Browse latest Browse all 11712

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>