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

Highlight Feature Problem

13 REPLIES 13
Reply
Message 1 of 14
Anonymous
723 Views, 13 Replies

Highlight Feature Problem

Dear all:

I wrote a function like this :

internal static void SelectFeatureToScreen(string layerName, string
filter)
{
AcMapMap currentMap = AcMapMap.GetCurrentMap();
AcMapFeatureService featureService =
AcMapServiceFactory.GetService(MgServiceType.FeatureService) as
AcMapFeatureService;

MgLayerCollection layers = currentMap.GetLayers();
AcMapLayer layer = layers.GetItem(layerName) as AcMapLayer;

MgFeatureQueryOptions query = new MgFeatureQueryOptions();
query.SetFilter(filter);

MgFeatureReader featureReader = layer.SelectFeatures(query);
MgSelectionBase selection = new MgSelectionBase(currentMap);
selection.AddFeatures(layer, featureReader, 0);

currentMap.SetFeatureSelection(selection, true);
currentMap.HilightFeature(HighlightMode.Glow, selection);
}

after execute this code, I expected to see some feature highlighted on
screen, but none.

I traced and found that featureReader indeed had rows I query,
but seemed not converted to selection.

Can anyone give me a clue to solve this problem ? thx a lot...


yapin 2007/07/25
13 REPLIES 13
Message 2 of 14
FcoLomas
in reply to: Anonymous

maybe can you add this:

MgSelectionBase selection = currentMap.GetFeatureSelection();

after this:

currentMap.SetFeatureSelection(selection, true);

and try again?? Can you tell us the result??
Message 3 of 14
FcoLomas
in reply to: Anonymous

sorry please in the last code dont use the class def, that object is already defined, so:

selection = currentMap.GetFeatureSelection();

Sorry!!
Message 4 of 14
senthilvelanj
in reply to: Anonymous

Hi,
I am using the same method in my application. The GetFeatureSelection works good with sdf or any other connection but not in oracle spatial.

When ever i call 'GetFeatureSelection' method with oracle spatial connection, it throws a 'Logic exception Error'. Can u help me in this regard.

Thanks in Advance.

Velan.
Message 5 of 14
FcoLomas
in reply to: Anonymous

I really a little bit rare, I use the same method and get no problems, but something that i would like to check is your filter expression, maybe is empty or oracle doesn't support the expression given or the filter isn't right...
If you analyze the FDO objects you can notice that are custom implementations of generic .NET ADO objects, understanding that maybe you can try to review your code to use that object a little bit different..

Well check your filter expresion, surround your code with a Try/Catch block, try to get the most info from the exception and tell us please!!!
Message 6 of 14
senthilvelanj
in reply to: Anonymous

Thanks for the quick reply.

Sorry, I missed to mention an important thing. That is I am trying to read the features which are selected in the AutoCAD Map. I have checked with the 'PolygonOperation' Map Sample given in Map ObjectArx SDK 2008. The sample is working fine even i connect sdf files and select the features manually . When I check with oracle spatial table in the same sample application it throws Logic exception error.

This is the block of the code

AcMapMap currentMap = AcMapMap.GetCurrentMap();
try
{
MgSelectionBase selection = currentMap.GetFeatureSelection();

MgReadOnlyLayerCollection selectedlayers = selection.GetLayers();

MessageBox.Show(selectedlayers.Count.ToString());

....
....
....

}
catch (MgLogicException ex)
{
MessageBox.Show((ex.Message);
}

Exception Details
-----------------

Message = "Logic Exception"
Source = "AcMapApiMgd"
StackTrace = "- AcMapMap.AddIdToSelection line 1230 file .\\AcMapMap.cpp\n"


Hope these details explain the problem.
Message 7 of 14
FcoLomas
in reply to: Anonymous

I have seen that error, well I really don't why but something that I tried is to assure that my feature is seleted before the code is going to be executed, then the code works, remember that the code that we're using is an preview and sometimes will have this kind of errors...
And please can you put a break point on the first line of the try and tell us where is the code throwing the exception??
Message 8 of 14
senthilvelanj
in reply to: Anonymous

The code is throwing the exception in the following line

MgSelectionBase selection = currentMap.GetFeatureSelection();

But it is only with OracleProvider connections. All others connections are working fine..
Message 9 of 14
abolail
in reply to: Anonymous

look, i think you have to use selection.AddFeatureIdInt64 function, it works good:
While (reader.ReadNext())
featId as integer=reader.getInt64("FeatId")
selection.AddFeatureIdInt64(layer,layer.FeatureClassName,featId)
End While
currentMap.HilightFeature(HighlightMode.Glow, selection);


try it, i have another problem, it hilight the features until their count is less than 480, if their count is more than that it failed and i get an exception.
i hope anyone know what i'm talking about...

thanks.
Message 10 of 14
dmalav
in reply to: Anonymous

I am trying to add similar kind of functionality to my code. I downloaded the Map 3D ObjectARX but I do not see AcMapMap, AcMapLayer or MgFeatureReader classes anywhere. Is there some other API that I need to download?
Any help would be much appreciated.
Message 11 of 14
senthilvelanj
in reply to: Anonymous

You can find these functions used in the samples projects available with Map ObjectARX SDK 2008 / 2009. The path is ..\\Map ObjectARX SDK 2008\\Map Samples\Platform. Take a look into sdk.dev.net.gis.chm in the help folder of Autocad Map3D 2008.
Message 12 of 14
dmalav
in reply to: Anonymous

Hi Velan,
Were you able to fix your problem you were having with Oracle connection for the code:

MgSelectionBase selection = currentMap.GetFeatureSelection();

I am having the same exception, but it happens only if I have a join on the layer I am selecting.

Thanks in advance for the help.
Message 13 of 14
mmgehlot
in reply to: Anonymous

hi dear,
please tell me about somthing in gis and autocad
Message 14 of 14
garywhitcher4614
in reply to: Anonymous

Hi All:

I have been a VB6/VBA programmer for AutoCAD for a very long time but now I am trying to switch over to .NET.

I have run into a problem. I can not seem to find anywhere how to get a list of the coordinate systems within AutoCAD 3D Map. I do not which dll to reference, which imports to use etc....

I am very frustrated with this as I am new to programming GIS related functions within AutoCAD.

Can anyone help me with this? My sanity would be saved if so...Thanks!

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

Post to forums  

Autodesk Design & Make Report

”Boost