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

File uploaded by Joyce Bossom Employee on Dec 17, 2010Last modified by Joyce Bossom Employee on Nov 2, 2017
Version 6Show Document
  • View in full screen mode

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.

Attachments

Outcomes