public static class EditorSelectionExtension
{
public static PromptSelectionResult SelectAtPickBox(
this Editor ed, Point3d pickBoxCentre)
{
//Get pick box's size on screen
System.Windows.Point screenPt = ed.PointToScreen(pickBoxCentre, 1);
//Get pickbox's size. Note, the number obtained from
//system variable "PICKBOX" is actually the half of
//pickbox's width/height
object pBox = Application.GetSystemVariable("PICKBOX");
int pSize = Convert.ToInt32(pBox);
//Define a Point3dCollection for CrossingWindow selecting
Point3dCollection points = new Point3dCollection();
System.Drawing.Point p;
Point3d pt;
p = new System.Drawing.Point((int)screenPt.X - pSize, (int)screenPt.Y - pSize);
pt = ed.PointToWorld(p, 1);
points.Add(pt);
p = new System.Drawing.Point((int) screenPt.X + pSize, (int)screenPt.Y - pSize);
pt = ed.PointToWorld(p, 1);
points.Add(pt);
p = new System.Drawing.Point((int) screenPt.X + pSize, (int) screenPt.Y + pSize);
pt = ed.PointToWorld(p, 1);
points.Add(pt);
p = new System.Drawing.Point( (int)screenPt.X - pSize, (int) screenPt.Y + pSize);
pt = ed.PointToWorld(p, 1);
points.Add(pt);
return ed.SelectCrossingPolygon(points);
}
}
Created
March 24, 2018 02:23
-
-
Save benkoshy/eef30090c975d083a340f5bdda937b59 to your computer and use it in GitHub Desktop.
Norman's Extension Method but casts to Integer
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment