Troubleshooting mathTransforms, ivertex getpoints, and Views/Sketches.

Please excuse the long explanation.

I'm trying to write a macro that will eventually be able to circle user-specified sub-assemblies on a drawing view. I've finished what I thought was the hard part of this process and am now trying to get mathpoints (in the reference frame for a Sketch on an active drawing view) from all vertices on that drawing view. These mathpoints will then be processed to find the convex hull of the 2D "point cloud" and the points on the hull will be scaled about their centroid and used to create a closed spline.

2012 SOLIDWORKS API Help - GetPoint Method (IVertex)

To collect the mathPoints, I'm using swVertex.getPoint() for every visible vertex on an active drawing view. My problem is that I can't figure out what coordinate system these vertices are reporting their points with respect to. I feel like I'm missing something fundamental about how to transform from a referenced model to a drawing to a view in that drawing. It would be helpful if: the methods that return mathtransforms explicitly described what they were transforming to and from and if methods that report dimensions documented what reference frame they are reported with respect to.

    Set swViewComponent = swView.RootDrawingComponent.Component

   

    If swView.GetVisibleEntityCount(swViewComponent, swViewEntityType_e.swViewEntityType_Vertex) > 0 Then

        math_point_iterator = 0

        For Each vVisibleEntity In swView.GetVisibleEntities(swViewComponent, swViewEntityType_e.swViewEntityType_Vertex)

            Set swEntity = vVisibleEntity

            Set swVertex = swEntity

            Set swMathPoint = swMathUtility.CreatePoint(swVertex.GetPoint)

            ReDim Preserve swMathPoints(math_point_iterator)

            Set swMathPoints(math_point_iterator) = swMathPoint

            math_point_iterator = math_point_iterator + 1

        Next vVisibleEntity

    End If

I've taken these points and used swView.ModelToViewTransform and attempted to pass them to the sketch manager to draw on the sketch associated with the active view.

I've tried drawing them on the sketch associated with the current sheet.

I've tried every combination of swView.ModelToViewTransform and swSketch.ModelToSketchTransform (inverted both, inverted their product, inverted one or the other, did all of those things after changing the order of muiltiplication, omitted one, omitted the other). None of these approaches have gotten me sketch points that align with the vertices visible in the drawing view.

When I use the mis-aligned sketchpoints with my convexhull spline operation and manually drag the feature over, it looks great. I just can't get it to align with the view automatically.

If the sketchpoints align with the vertices, the scale is off. If the scale is correct, they don't align. If the scale and alignment are close, the orientation is wrong. I was going to write a detailed analysis of everything that I have tried but the list is so long at this point, I don't know that it will add clarity. Is there something fundamentally wrong with my approach?

I have transformed into and out of a model in a drawing view successfully in the past. The application involved drawing grid lines for a view in a drawing that aligned with a custom coordinate system int he model. When I try to apply what I learned with that project, it doesn't work.

SolidworksApi macros