Highlight Feature Problem

Highlight Feature Problem

Anonymous
Not applicable
888 Views
13 Replies
Message 1 of 14

Highlight Feature Problem

Anonymous
Not applicable
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
0 Likes
889 Views
13 Replies
Replies (13)
Message 2 of 14

Anonymous
Not applicable
maybe can you add this:

MgSelectionBase selection = currentMap.GetFeatureSelection();

after this:

currentMap.SetFeatureSelection(selection, true);

and try again?? Can you tell us the result??
0 Likes
Message 3 of 14

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

selection = currentMap.GetFeatureSelection();

Sorry!!
0 Likes
Message 4 of 14

Anonymous
Not applicable
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.
0 Likes
Message 5 of 14

Anonymous
Not applicable
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!!!
0 Likes
Message 6 of 14

Anonymous
Not applicable
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.
0 Likes
Message 7 of 14

Anonymous
Not applicable
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??
0 Likes
Message 8 of 14

Anonymous
Not applicable
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..
0 Likes
Message 9 of 14

Anonymous
Not applicable
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.
0 Likes
Message 10 of 14

Anonymous
Not applicable
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.
0 Likes
Message 11 of 14

Anonymous
Not applicable
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.
0 Likes
Message 12 of 14

Anonymous
Not applicable
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.
0 Likes
Message 13 of 14

Anonymous
Not applicable
hi dear,
please tell me about somthing in gis and autocad
0 Likes
Message 14 of 14

Anonymous
Not applicable
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!
0 Likes