POST
|
I tried mxd.save but again it saves the closed map document but does nothing to the open document. It only works on the closed mxd forcing me to open it again. Plus I do not want to save the changes, the idea is just to pop in the features for viewing to make sure they are correct and then discard them. I am currently working with ArcObjecs in another post: http://gis.stackexchange.com/questions/21450/add-layer-to-open-mxd-using-arcobjects-from-outside-the-map-document-crashes-arc, but ArcMap continues to crash when it is adding the layer. If anyone has an idea for either method I would be most grateful.
... View more
03-13-2012
06:42 AM
|
0
|
0
|
450
|
POST
|
Thank you for the advice. I posted the question on the forum under the following heading: Add layer to open mxd using ArcObjects from outside the map document. I will try to post a link to the answer, if I get one.
... View more
03-08-2012
04:54 AM
|
0
|
0
|
450
|
POST
|
I know, that is why I am trying to prepare for 10.1. I figure while I am upgrading everything else I might as well upgrade everything I will need to for 10.1 as well.
... View more
03-07-2012
10:39 AM
|
0
|
0
|
450
|
POST
|
I have an Access database (MS Access 2010) that allows users to enter a variety of land treatment information including associated points, lines, or polygons which users can select and the database would then load as part of the project, to a master geodatabase, and allow the user to view the features in an ArcMap. In Arc 9.3 this was all accomplished with VBA and worked well. Because of the upgrade to Arc 10, VBA is no longer an option and I have been learning how to program in python and call the commands through Access using the Shell feature. I have nearly completed everything except for the ability to allow users to add their feature to the current ArcMap document. Here are the steps that should occur. 1) User clicks a button in the Access program which identifes the feature(s) of interest and calls the python shell. 2) Access determines if the correct mxd is open and if not opens it (the document is usually open so this step is often uneccessary) 3) The Python script opens using the shell command, identifes the correct and open mxd, and adds feature to the open ArcMap document The python script works fine if I run it within the open ArcMap document using the mxd = arcpy.mapping.MapDocument("CURRENT") arpy command code. However, if I run the command using the python shell and mxd = arcpy.mapping.MapDocument(r"C:\CreateShapefile\CreateShapefile10x.mxd") it will manipulate the document if it is closed and I instruct python to save the changes but will not display any changes on the open ArcMap document even if I refresh the TOC and Active View. I have tried working with ArcObjects and Comtypes to accomplish this as well as arcpy.mapping but with no luck. I think arcpy should be able to accomplish this but again running the program through IDLE or python shell doesn't manipulate the open ArcMap document. I need a way to manipulate an open ArcMap document from outside the current ArcMap session. All the code seems to work when run from within the mxd, just not if called through Python shell or IDLE. The code attached is simply to turn on a background layer in the open mxd but even this does not work when run through IDLE, only if I save the mxd and then open it will the change appear. import arcpy
import arcpy.mapping
mxd = arcpy.mapping.MapDocument(r"C:\CreateShapefile\CreateShapefile10x.mxd")
for df in arcpy.mapping.ListDataFrames(mxd):
arcpy.AddMessage("DataFrame Found: " + df.name)
# Select the LTDL Layers Dataframe
if df.name == "LTDL Layers":
print df.name
LayersOn = ["us topo map"]
for lyr in arcpy.mapping.ListLayers(mxd, "", df):
for lr in LayersOn:
if lyr.name.lower() == lr:
lyr.visible = True
arcpy.RefreshTOC()
arcpy.RefreshActiveView()
print "Done"
... View more
03-07-2012
09:29 AM
|
0
|
6
|
2395
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|