How to get the pixel coordinates of the sketch point on the screen

How to get the pixel coordinates of the sketch point on the screen

lzs013
Advocate Advocate
1,050 Views
2 Replies
Message 1 of 3

How to get the pixel coordinates of the sketch point on the screen

lzs013
Advocate
Advocate

By learning this post, I can easily get the mouse model position and view position. Similarly, I can get the space coordinates of the sketch point through VBA, but how to get the coordinates of the sketch point on the screen? The screen coordinates are in pixels, and the coordinates of a fixed sketch point on the screen can be changed continuously.

0 Likes
Accepted solutions (1)
1,051 Views
2 Replies
Replies (2)
Message 2 of 3

BrianEkins
Mentor
Mentor
Accepted solution

To go from sketch space to view space you need to first get 3D point in model space that is equivalent to the 2D sketch point and then you can get the view point where the 3D point currently is on the screen.  The returned point is relative to the window containing the view and is in pixels.

 

 

Dim skCoord As Point2D
Dim sk As PlanarSketch
GetAPointInSketchSpaceSomehow(skCoord, sk)

Dim modelPoint as Point
modelPoint = sk.SketchToModelSpace(skCoord)

Dim viewPoint as Point2D
Dim cam as Camera = ThisApplication.ActiveView.Camera
viewPoint = cam.ModelToViewSpace(modelPoint)

 

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 3 of 3

lzs013
Advocate
Advocate

Thank you very much, you completely solved my problem.

0 Likes