- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I try to hide some part of polyline when it across a block. I used overrule to hide it but not success because the WorldDraw method not allow me to use Document doc = Application.DocumentManager.MdiActiveDocument;.
In the WorldDraw method, I wrote some code to select blocks that across the polyline and find the intersection between the polyline and blocks. so I need to use Editor.SelectFence() to select block object.
Have any ways to avoid this? Thanks in advances.
my code:
public override bool WorldDraw(Drawable drawable, WorldDraw wd)
{
GrxCAD.DatabaseServices.Polyline pl = drawable as GrxCAD.DatabaseServices.Polyline;
DBObject plobj = drawable as GrxCAD.DatabaseServices.DBObject;
Document doc = Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
if (_overruling)
{
// Get xdata
List<HiddenSegment> hs = ReadXDataHiddenSegment(plobj);
// Get polyline's vertices
Point3d[] pts = new Point3d[pl.NumberOfVertices];
for (int i = 0; i < pl.NumberOfVertices; i++)
{
pts[i] = pl.GetPoint3dAt(i);
}
// Draw each segments
int n = 0;
//Tolerance tol = new Tolerance(0.0001, 0.0001);
while (n < pts.Length)
{
if ((n + 1) < pts.Length)
{
// create fence to select
Point3dCollection fe = new Point3dCollection
{
pts[n],
pts[n + 1]
};
// select object that the segment was across
PromptSelectionResult PromptSel = ed.SelectFence(fe);
// if objects were found on the current segment.
if ((PromptSel.Status == PromptStatus.OK) && (PromptSel.Value.Count > 0))
{
SelectionSet sset = PromptSel.Value;
// get all intersection points between the segment and objects
foreach (SelectedObject selobj in sset)
{
// get the intersection points (between pline and object)
Point3dCollection interPt = EntityInters.GetIntersectionPointInAndOut(selobj.ObjectId, plobj.ObjectId);
if (interPt.Count == 2)
{
fe.Add(interPt[0]);
fe.Add(interPt[1]);
}
}
// sorting all points
Point3dCollection SortedFe = SortPoints.SortPoint3d(fe);
// draw
int i = 0;
while (i < pts.Length)
{
if ((i + 1) < pts.Length)
wd.Geometry.WorldLine(SortedFe[i], SortedFe[i + 1]);
i += 2;
}
} else
{
wd.Geometry.WorldLine(pts[n], pts[n + 1]);
}
}
n += 1;
}
return true;
}
else
{
return base.WorldDraw(drawable, wd);
}
}
Solved! Go to Solution.