Message 1 of 2
Align cursor position with preview Revit snap
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi all,
Currently, I get the mouse position in the Revit environment as follows
var uiView = uiDocument.GetOpenUIViews().First(x => x.ViewId == uiDocument.ActiveView.Id);
var corners = uiView.GetZoomCorners();
var rect = uiView.GetWindowRectangle();
var position = System.Windows.Forms.Cursor.Position;
var dx = (double)(position.X - rect.Left) / (rect.Right - rect.Left);
var dy = (double)(position.Y - rect.Bottom) / (rect.Top - rect.Bottom);
var minPoint = corners[0];
var maxPoint = corners[1];
var vector = maxPoint - minPoint;
var mousePoint = minPoint + dx * vector.X * XYZ.BasisX + dy * vector.Y * XYZ.BasisY;
Because of the snap, in Revit, 2 points (snap, cursor position) as shown below are considered the same, how to get the mouse position at the snap position before clicking.
Thanks