I'm trying to modify the scale of the map so I can further export to pdf.
The mxd document has a fixed map scale option set. The initial value is 250 and final is still 250 unchanged. The code looks like this:
mxdPath = GetResPath() + "\\Template.mxd" mapDoc = NewObj(esriCarto.MapDocument, esriCarto.IMapDocument) mapDoc.Open(mxdPath) pActiveView = mapDoc.ActiveView pFeatureLayer = pGPUtil.OpenFeatureLayerFromString(path) pLayer = CType(pFeatureLayer, esriCarto.ILayer) pMap = mapDoc.Map pMap.MapScale = 500.0 #this will change the value, but the mxd just doesn't care pMap.AddLayer(pLayer) pActiveView.Refresh() outDocumentPath = GetTempPath() + "\\Document.mxd" mapDoc.SaveAs(outDocumentPath) mapDoc.Close()
I also want to mention that setting the Extent through pActiveView.Extent works, but it's harder to get an extent out of a scale
EDIT 1: I have already tried with both Automatic and fixed, on Automatic if I try to get the property it will throw and Exception and if I try to set the property nothing happens also.
EDIT 2: It seems the ArcObjects does actually modify the MapScale when setting the property, but it won't save this option when calling
mapDoc.Close(). The workaround was to load the
.mxd again using ArcPy and setting the
I hope this is helpful for people having related problems!