Community
Civil 3D Customization
Welcome to Autodesk’s AutoCAD Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Query to filter objects on layers using .NET

0 REPLIES 0
Reply
Message 1 of 1
Anonymous
405 Views, 0 Replies

Query to filter objects on layers using .NET

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();

Tags (3)
0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


 

Autodesk Design & Make Report