- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have noticed a strange behavior while creating a selection set. my program gets two corners of a rectangle to create a window selectionset, then passes the two points to another method to create the selection set. but the user has to pick an object fist, so the program could find out whats the type of the object to make its filter, also to find out the layer that it has to filter.
whats strange is, this is the window that Im selecting:
then I zoom in to pick a block object,
surprisingly, the operation which in my case is trimming the lines inside the blocks, only trims the lines which are seen on the zoomed screen! I even added a watch on my selection set and noticed that
var selectionResult = ed.SelectWindow(firstCorner, secondCorner,selectionFilter) does not care about the specified corners and instead uses the zoomed window cordination instead!
I think, I had the same issue with VBA?! I'm not sure though.
how can I fix this problem?
private static SelectionSet CreateSelectionSet(Document doc, string objectType
, List<Point3d> pointList, Type type)
{
var ed = doc.Editor;
var db = doc.Database;
using (var tr = db.TransactionManager.StartTransaction())
{
Entity entity = null;
string objectLayer = "SPRKVIEW";
var strType = type.ToString().Substring(34, type.ToString().Length-34);
try
{
if ((objectType.ToUpper()=="LINE" || objectType.ToUpper()=="INSERT"))
{
var peo = new PromptEntityOptions("\nSelect a " + strType +
" represting the desired object");
peo.SetRejectMessage("\nNot a valid Object! Select a " + strType);
peo.AddAllowedClass(type , true);
peo.AllowNone=true;
peo.AllowObjectOnLockedLayer=true;
var res = ed.GetEntity(peo);
entity = tr.GetObject(res.ObjectId, OpenMode.ForRead) as Entity;
if (res.Status != PromptStatus.OK)
{
tr.Abort();
return null;
}
objectLayer = entity.Layer;
}
var firstCorner = pointList[0];
var secondCorner = pointList[1];
var filterValue = new TypedValue[2];
filterValue.SetValue(new TypedValue((int)DxfCode.Start, objectType), 0);
filterValue.SetValue(new TypedValue((int)DxfCode.LayerName, objectLayer), 1);
var selectionFilter = new SelectionFilter(filterValue);
var selectionResult = ed.SelectWindow(firstCorner, secondCorner, selectionFilter);
var selectionSet = selectionResult.Value as SelectionSet;
if (selectionSet!=null)
{
tr.Commit();
return selectionSet;
}
else
{
tr.Abort();
return null;
}
}
catch (System.Exception ex)
{
Application.ShowAlertDialog("Error occured: " + ex.Message);
return null;
}
}
}
Solved! Go to Solution.