Hi,
I need to hide and show entities in my drawing, I want to do this by setting the visibility property on the entities.
To select the entities in the drawing I am using a selection set with a filter. In the filter I use DxfCode.Visibility to select the entities. The DxfCode.Visibility in the filter works when the entities are visible and I set the visibility code to zero. I.e. it returns the entities as expected.
However after I have set the entitles visible property to false and they are hidden and I want to select them again so I can make them visible, I reuse the same filter but I set the DxfCode.visibility to 1. When I execute the selection set the PromptSelectionResult status is set to "Error". (I.e. result.Status == PromptStatus.Error)
Does anyone have experience with selecting invisible entities and can explain how I might do this?
This snippet is where I use the selection set:
TypedValue[] values = ReturnEntityDxfCodes(entities_are_visible);
SelectionFilter filter =
new SelectionFilter(values);
PromptSelectionResult res =
ed.SelectCrossingWindow(new Point3d(extents.Max3d.ToArray()),
new Point3d(extents.Min3d.ToArray()), filter);
if (res.Status == PromptStatus.OK)
{
if (res.Value != null)
{
ObjectId[] obj_ids = res.Value.GetObjectIds();
return obj_ids;
}
}
This is where I set the Dxf Codes, the last one selects visibility (this works if the entities are visible)
private TypedValue[] ReturnEntityDxfCodes(bool entities_are_visible)
{
int visible = 0;
if (!entities_are_visible)
visible = 1;
TypedValue[] values =
{
new TypedValue(
-4,
"<OR"
),new TypedValue(
(int)DxfCode.Start,
"Circle"
),new TypedValue(
(int)DxfCode.Start,
"Point"
),new TypedValue(
(int)DxfCode.Start,
"Insert"
),new TypedValue(
(int)DxfCode.Start,
"Line"
),new TypedValue(
(int)DxfCode.Start,
"LWPOLYLINE"
),new TypedValue(
(int)DxfCode.Start,
"POLYLINE"
),new TypedValue(
-4,
"OR>"
),new TypedValue(
-4,
"<AND"
),new TypedValue(
(int)DxfCode.Visibility,
visible
),new TypedValue(
-4,
"AND>"
)
};
return values;
}
To test the way I set the dxf codes I set only the dxfCode for visibility
if (!entities_are_visible)
{
TypedValue[] invisible_dxfcode =
{
new TypedValue(
(int)DxfCode.Visibility,
1
)
};
return invisible_dxfcode;
}
I had the same result with this, the result.Status flag was set to "Error".