API: How to locate a model entity in the space of a drawing view (VBA, VB.NET, C#)

Version 5

    This example shows how to locate a model entity in the space of a drawing view.

     

    Problem:

     

    Points selected in a drawing are returned in the space of the underlying model, rather than in the space of the drawing sheet. Given a selection point in the space of the model, where is that point in the space of the drawing view?

     

    Solution:

     

    This example shows how to use the transform-related APIs to go from model space to drawing view space.

    The APIs used are:

     

              View.GetViewXform
              View.GetXform

     

    Various MathUtility APIs are also used and make dealing with transforms a lot easier.

     

    1. Extract the archive in a convenient location.
    2. Open a drawing with circular edges in SolidWorks.
    3. Select a circular edge in a view.
    4. Open the macro file in the Macro Editor.
    5. Run the macro.

     

    A cross is placed at the center of the circle described by the selected circular edge.

     

    Notes:
    This code is not intended to be used as an alternative to DrawingDoc::InsertCenterMark.
    This code illustrates the technique of inserting a cross to confirm that we have correctly done our model to drawing transformation.

     

    Note:
    - Subscription Services required for full access.

    - Looking for more API Examples?

     

    Copyright © 2011 Dassault Systèmes SolidWorks Corp. All rights reserved.
    Do not distribute or reproduce without the written consent of Dassault Systèmes SolidWorks Corp.