Message 1 of 11
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi,
I am trying to select Lines and Circles that reside inside a polyline but I failed , can anyone point me to the error in my codes please?
Is there any other way than highlight method to select objects as if you are selecting them in Autocad ? I mean selection with grips .
Thanks in advance.
public static void HighLightObjects()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
PromptEntityOptions sel = new PromptEntityOptions("\nSelect Polyline :");
sel.SetRejectMessage("Must be Polyline");
sel.AddAllowedClass(typeof(Polyline), true);
sel.AllowNone = false;
PromptEntityResult s = ed.GetEntity(sel);
if (s.Status == PromptStatus.OK)
{
using (Transaction trans = db.TransactionManager.StartTransaction())
{
try
{
Polyline pl = (Polyline)trans.GetObject(s.ObjectId, OpenMode.ForRead);
Double len = pl.Length;
Double dis = len / 250;
Double gap = dis;
int run = ((int)dis);
Point3dCollection lst = new Point3dCollection();
lst.Add(pl.GetPointAtParameter(0));
for (int i = 0; i < run; i++)
{
Point3d p = pl.GetPointAtDist(dis);
dis = dis + gap;
lst.Add(p);
}
PromptSelectionOptions ss = new PromptSelectionOptions();
TypedValue[] tv = { new TypedValue(0, "CIRCLE"), new TypedValue (0 , "LINE") };
SelectionFilter ftr = new SelectionFilter(tv);
PromptSelectionResult res = ed.SelectCrossingPolygon(lst, ftr);
if (res.Status == PromptStatus.OK)
{
foreach (var item in res.Value.GetObjectIds())
{
Entity c = (Entity)trans.GetObject(item, OpenMode.ForRead);
c.Highlight();
}
}
}
catch (System.Exception ex)
{
ed.WriteMessage(ex.Message);
}
}
}
}
Solved! Go to Solution.