AutoCAD Map 3D Developer

AutoCAD Map 3D Developer

Reply
Mentor
Robert_Fritz
Posts: 175
Registered: ‎12-08-2011
Message 1 of 4 (560 Views)
Accepted Solution

Check if AutoCAD selection set contains FDO features?

560 Views, 3 Replies
09-05-2012 05:49 AM

Hi,

 

is there a reliable way to check if selected objects are Map FDO features?

 

It seems no checking is done here:

 

http://adndevblog.typepad.com/infrastructure/2012/07/using-acmapfeatureentityservicegetselection-to-...

 

but checking is done here:

 

http://forums.autodesk.com/t5/AutoCAD-Map-3D-Developer/FDO-object-properties-through-GetEntity/td-p/...

 

which I haven't tried myself yet but it doesn't look right to me to rely on this construct:

 

if (ent.Layer!="*ACMAPDMGISENTITIES") ....

 

What I have is:

 

 MgSelectionBase selectionBase = AcMapFeatureEntityService.GetSelection(selSet);

 

but I need to filter out all non-FDO objects in "selSet". Any ideas?

 

many thanks,

Rob

 

http://raumpatrouille3d.blogspot.ch/

Unless AutoCAD Map has a radically different implementation of MgSelectionBase from MapGuide, the GetLayers() method of MgSelectionBase returns null for empty selections

 

So selectionBase.GetLayers() == null means no features selected

 

- Jackie

Hi Jackie,

 

many thanks - that's the solution,

 

Rob

Mentor
Robert_Fritz
Posts: 175
Registered: ‎12-08-2011
Message 2 of 4 (557 Views)

Re: Check if AutoCAD selection set contains FDO features?

09-05-2012 07:04 AM in reply to: Robert_Fritz

 

Hi,

 

my issue is actually slighty different then described above.

 

For me it doesn't matter if there are FDO and CAD objects mixed in the selection set. The problem arises if only CAD objects have been selected. I need to find out if that is the case. But I do not know how.

 

If only an ACAD object has been selected I get a System.NullReferenceException. So I added a check whether the object in question is null or not. But it doesn't seem to be null or my check is wrong?

 

MgSelectionBase selectionBase = AcMapFeatureEntityService.GetSelection(selSet);

if (selectionBase != null)

...//ok

else

 return; //stop

 

 

It never follows the Else branch - but then I get the aformentioned exception later on at

 

selectionBase.GetLayers().Count

 

 

Any ideas?

 

Rob

 

http://raumpatrouille3d.blogspot.ch/
Valued Mentor
jackie.ng
Posts: 284
Registered: ‎10-06-2008
Message 3 of 4 (548 Views)

Re: Check if AutoCAD selection set contains FDO features?

09-06-2012 08:39 PM in reply to: Robert_Fritz

Unless AutoCAD Map has a radically different implementation of MgSelectionBase from MapGuide, the GetLayers() method of MgSelectionBase returns null for empty selections

 

So selectionBase.GetLayers() == null means no features selected

 

- Jackie

Mentor
Robert_Fritz
Posts: 175
Registered: ‎12-08-2011
Message 4 of 4 (540 Views)

Re: Check if AutoCAD selection set contains FDO features?

09-07-2012 05:12 AM in reply to: jackie.ng

Hi Jackie,

 

many thanks - that's the solution,

 

Rob

http://raumpatrouille3d.blogspot.ch/
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.