Skip to content

Instantly share code, notes, and snippets.

@benkoshy
Created March 24, 2018 02:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benkoshy/eef30090c975d083a340f5bdda937b59 to your computer and use it in GitHub Desktop.
Save benkoshy/eef30090c975d083a340f5bdda937b59 to your computer and use it in GitHub Desktop.
Norman's Extension Method but casts to Integer
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);
        }
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment