Hello.
I am trying to make a simple .NET form to filter objects based on data saved in shp files, which are connected to a dwg map. I just need to show (in the map) the objects which meet specific criteria which are set by user in a form. For example: an attribute CAO > 40.
I enclose code snippet which I thought should do the trick. But it does nothing (visually).
Please any suggestion will be more than welcome.
Thank very much.
//method to make a selection
private void FeatureSelection(object sender, EventArgs e)
{
MgFeatureQueryOptions opts = new MgFeatureQueryOptions();
opts.SetFilter("CAO > 40");
foreach (AcMapLayer layer in layers)
{
MgResourceIdentifier featureId = new MgResourceIdentifier(layer.GetFeatureSourceId());
MgFeatureReader reader = layer.SelectFeatures(opts);
AcMapSelection selection = new AcMapSelection(currentMap);
selection.AddFeatures(layer, reader, 0);
reader.Close();
if (layer.Visible == true)
layer.SetFeatureVisibility(selection, true);
}
//refresh
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.Regen();
}