Set Layer ID for a layer in ArcMap 10.3

13741
13
Jump to solution
04-10-2015 02:10 AM
MichaelWinther1
New Contributor II

Right now we have a lot of mxds with grouplayers (even som grouplayers with grouplayers).

If I import a .lyr file in ArcMap all layerids will be -1.

I'm trying to set the Layer Id for an ILayer in an mxd document but cannot find any ArcObjects interfaces exposing this property.

ILayerDescriptions needs server objects.

Any help is appreciated.

Tags (2)
0 Kudos
13 Replies
nicogis
MVP Frequent Contributor

Hi Alessandro,

p return 50

k return 3

IMapDocument mapDocument = new MapDocumentClass();
mapDocument.Open(@"C:\Temp\Scratch\testanno.mxd");
IMap b = mapDocument.get_Map(0);
ILayerExtensions c = b.get_Layer(0) as ILayerExtensions;
var p = (c.get_Extension(0) as IServerLayerExtension).ServerProperties.GetProperty("ServicelayerID");
var k = (((b.get_Layer(0) as ICompositeLayer2).get_Layer(0) as ILayerExtensions).get_Extension(0) as IServerLayerExtension).ServerProperties.GetProperty("ServicelayerID");
0 Kudos
AlessandroRussodivito
Esri Contributor

Hi Domenico,

Thank you for the hint!

Unfortunately testing your code using 10.3.1, I could not solve the problem.

ICompositeLayer2 allows me to access sublayer of the annotation Layer (using ((anLayer as ICompositeLayer2).get_Layer(0) ), but the cast to ILayerExtentions of the sublayer is not working.

I guess this is because of a difference in Interfaces implementation between Annotation Layer and Annotation Sub Layer (which should be a BUG addressed in greater versions)

FDOGraphicsLayer has the Interface ILayerExtentions :ArcObjects Help for .NET developers 

While for FDOGraphicsSublayer, ILayerExtentions is missing: -> ArcObjects Help for .NET developers 

Are you using a different version (greater than 10.3.1) ?

Thanks,

Alessandro

0 Kudos
nicogis
MVP Frequent Contributor

I have tested with 10.7. 

10.3.1 is retired december 2020

0 Kudos
AlessandroRussodivito
Esri Contributor

I know, 10.7 has the correct intefaces.

I was wondering if ILayerExtentions could be added coding even to Annotation sublayers in 10.3.1, as Michael previously stated:

"

Just need to take care of my layers not having any ILayerExtensions.

Fixed it by just creating one and adding it to the layer.

"

Your hints are always appreciated,

Thanks

Alessandro

0 Kudos