| Article | 60000205 |
| Type | HowTo |
| Product | Engine |
| Date Added | 7/20/2007 12:00:00 AM |
| Fixed | (7/20/2007 12:00:00 AM) |
| Submitted by | Dominique PREMILLIEU |
Summary
What would be the best way to find an entity displayed under the cursor ? I would like this selection to detect entity from the current document or any xref attachment.
Solution
object ret = vdFramedControl1.BaseControl.ActiveDocument.ActionUtility.getUserPoint();
if (ret is VectorDraw.Geometry.gPoint)
{
VectorDraw.Geometry.gPoint p1 = vdFramedControl1.BaseControl.ActiveDocument.World2PixelMatrix.Transform(ret as VectorDraw.Geometry.gPoint);
Point location = new Point((int)p1.x, (int)p1.y);// This code will return the xREF as vdInsert
VectorDraw.Professional.vdPrimaries.vdFigure fig = vdFramedControl1.BaseControl.ActiveDocument.ActiveLayOut.GetEntityFromPoint(location, vdFramedControl1.BaseControl.ActiveDocument.ActiveLayOut.Render.GlobalProperties.PickSize, false);
if (fig != null)
{
fig.HighLight = true;
fig.Invalidate();
MessageBox.Show("Figure is a : " + fig.ToString());
fig.HighLight = false;
fig.Invalidate();
}// This code will return the inner entity, this is what you want
VectorDraw.Professional.vdPrimaries.vdFigure outerfig; // this should be the xREF vdInsert
VectorDraw.Geometry.Matrix matr = new VectorDraw.Geometry.Matrix();
VectorDraw.Professional.vdPrimaries.vdFigure innerfig = vdFramedControl1.BaseControl.ActiveDocument.ActiveLayOut.GetInnerEntityFromPoint(out matr, out outerfig, location, vdFramedControl1.BaseControl.ActiveDocument.ActiveLayOut.Render.GlobalProperties.PickSize, false);
if (innerfig != null && outerfig != null)
{
innerfig.HighLight = true; //This is the inner entity you want.
innerfig.Invalidate();
MessageBox.Show("Figure is a : " + innerfig.ToString() + " contained in " + outerfig.ToString());
innerfig.HighLight = false;
innerfig.Invalidate();
}
}
