How to Handle Entity Selection and View Transformations in SolidWorks Drawings via API?

One of the most tedious parts of working with SolidWorks drawings through the API is entity selection.

I’m currently building a fully automated workflow where a Windows Forms application takes user-defined parameters and generates:

  • multiple parts
  • their assembly
  • and the corresponding drawings

The main challenge is making the drawings flexible. That means with different input parameters, all dimensions should still be positioned correctly and consistently — including those inside detail views and section views.

To achieve this, I’m trying to position dimensions programmatically using offsets based on the geometry. So ideally:

  • I determine where an entity (edge, vertex, etc.) is located
  • then apply a controlled offset for dimension placement

For this, I rely on selection methods like SelectByRay and SelectByID, which require accurate positioning (both local to the view and global to the sheet) which is manageable through the main views.

However, this becomes very difficult when dealing with:

  • detail views
  • section views
  • different view scales
  • transformations between model → view → sheet space

Maintaining these transformations manually is becoming unreliable, and I often struggle to get consistent and correct coordinates for selection.

Additionally:

  • looping through a view’s entities (e.g., visible edges) does not directly give me their positions in a usable coordinate system
  • I need accurate positions to determine the closest entity to a target point before selecting it

So my questions are:

  1. Is there a standard or recommended approach in the SolidWorks API for handling entity positioning and selection in drawings, especially across different view types (detail/section)?
  2. What is the correct way to handle transformations between model space, view space, and sheet space without manually juggling too many variables like scale and offsets?
  3. Is there a more robust alternative to SelectByRay for reliable entity selection when precise positioning is required?
  4. When iterating through entities in a drawing view, is there a proper way to retrieve their positions in a consistent coordinate system that can be used for comparison and selection?

Overall, I’m looking for a more stable and scalable approach than manually computing positions and relying heavily on ray-based selection.