1

if I need to work with classes MxDocument with the MapDocument that I have selected to work , for example style gallery, How can I instantiate ?

InitStandalone()

pMapDoc = CreateObject(esriCarto.MapDocument, interface = esriCarto.IMapDocument)
pMapDoc.Open(path)

pApp = GetApp()
pMxDoc = CType(pApp.Document, esriArcMapUI.IMxDocument)
pSG = CType(pMxDoc.StyleGallery, esriDisplay.IStyleGallery)

Can I relate this?

PolyGeo
  • 65,136
  • 29
  • 109
  • 338
Rio
  • 11
  • 3

1 Answers1

2

According to my opinion you are mixing something up. If you are writing some code to use inside a running ArcMap process you have to work with the IMxDocument. In a standalone application without ArcMap only using arcobjects you have to work with the IMapDocument to access an MXD. Using both at once does not work correctly.

If you like to access the style gallery with IMxDocument you can use its member IMxDocument.StyleGallery, which is loaded and instantiated by the ArcMap application automatically.

If you are working with an IMapDocument there is no such member because there is no style manager window loaded. If the StyleGallery is ever usable in combination with the IMapDocument, I would try to create it this way. But it is not tested.

pSG = CreateObject(Display.StyleGallery, interface = Display.IStyleGallery)
Propper
  • 611
  • 5
  • 20
  • Yes, but you should be able to open one using IMapDocument.Open, just don't forget to save it or your changes will be lost. You can only cast interfaces where they exist... have a browse of an answer I posted http://gis.stackexchange.com/questions/129456/guidelines-for-using-arcobjects-from-python/150711#150711 on reading the ArcObjects help to find the interfaces you need. – Michael Stimson Apr 26 '16 at 23:56
  • Sorry, I meant http://gis.stackexchange.com/questions/142734/arcobjects-python-add-jpg-to-layout/142909#142909 I hope this illuminates using ArcObjects help. – Michael Stimson Apr 27 '16 at 02:34