Many a times I have come across a question : How do I create an AutoCAD selection set from the Geospatial Platform selection set (MgSelectionBase) containing FDO features ?
Here is a C# code snippet demonstrating the steps -
AcMapMap currentMap = AcMapMap.GetCurrentMap();
MgLayerCollection layers = currentMap.GetLayers();
MgLayerBase layer = layers.GetItem("Parcels");
MgFeatureService fs = AcMapServiceFactory.GetService(MgServiceType.FeatureService) as MgFeatureService;
string fsId = layer.GetFeatureSourceId();
string className = layer.GetFeatureClassName();
MgFeatureQueryOptions query = new MgFeatureQueryOptions();
// Parcels.shp file is used
query.SetFilter("FeatId = 166");
MgResourceIdentifier resId = new MgResourceIdentifier(fsId);
MgFeatureReader featureReader = fs.SelectFeatures(resId, className, query);
MgSelectionBase selectionSet = new MgSelectionBase(currentMap);
//Add all features in the feature reader to the newly constructed selection set
selectionSet.AddFeatures(layer, featureReader, 0);
AcMapFeatureEntityService.HighlightFeatures(selectionSet);
// create an AutoCAD selection
SelectionSet acadSelSet = AcMapFeatureEntityService.AddFeaturesToSelectionSet(null, selectionSet);
Hope this is useful to you!

Leave a Reply