AutoCAD Map 3D Developer

AutoCAD Map 3D Developer

New Member
2 Posts
0 Kudos
Registered: ‎12-12-2010
Post 1 of 3

Implied selection problem

569 Views, 2 Replies
12-24-2010 08:56 AM

I have a problem when i try to run a commend called by a FeatureUpdated event, i try to select the implied selected feature using this code :


 Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor


Dim result As PromptSelectionResult = ed.SelectImplied()
        If result.Status <> PromptStatus.OK Then Exit Sub
        Dim MgSelBase As  MgSelectionBase = AcMapFeatureEntityService.GetSelection(result.Value)
        Dim Mglayers As MgReadOnlyLayerCollection = MgSelBase.GetLayers()
         Dim layerBase As MgLayerBase = MgSelBase.GetLayers(0)

Dim featReader As MgFeatureReader = MgSelBase.GetSelectedFeatures(layerBase, layerBase.FeatureClassName, False)

      While featReader.ReadNext
 ' operations

         End While
This code makes autocad crash
the same thing hapen when it's used by a user selection(ed.GetSelection(entOptions)) instead of an event
Has anyone encountered the same problem ?


*Expert Elite*
1,087 Posts
217 Kudos
Registered: ‎04-27-2009
Post 2 of 3

Re: Implied selection problem

12-30-2010 01:14 PM in reply to: olivierguy

1. Does your command method have CommandFlags.UserPickSet flag set?


2. Have you debugged the code so that you knowwhich line of code is the offending one? That is, does AutoCAD Map pass through this line:


 If result.Status <> PromptStatus.OK Then Exit Sub


If yes, then I think you need to test if the SelectionSet.Count>0 or not:


If result.Value.Count=0 Then Exit Sub


because if the count is 0, the next line of code would not get you a MgSelectionBase object.


Anyway, simply place a break point and then step through the code would allow you easily find the cause of crash.


New Member
2 Posts
0 Kudos
Registered: ‎12-12-2010
Post 3 of 3

Re: Implied selection problem

01-02-2011 01:38 AM in reply to: norman.yuan

Thank you for the reply


I have tried with and without CommandFlags.UserPickSet flag set, but there is the same result, Autocad crash when i try to get the layer of the MgSelBase. This is perhaps because i use this code with an event handler and when there are features checked out on the map, but i don't know.


I found another way to achieve what i wanted to do, i use the FeatureEventArgs of the eventhandler to identify the feature updated, instead of SelectImplied()


Handler added at the initialisation of the dll :

Dim fs As AcMapFeatureService = AcMapServiceFactory.GetService(MgServiceType.FeatureService)

        AddHandler fs.FeatureUpdated, AddressOf fs_FeatureUpdated


Function called when a modified feature is checked in :

Sub fs_FeatureUpdated(ByVal sender As Object, ByVal e As AcMapFeatureEventArgs)

        Dim feat As AcMapFeature = e.GetFeature()
 ' operations
End sub


Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!