|
POST
|
Arcpy.mapping can not be used to set up or modify DDP settings. This must be done in the UI. Jeff
... View more
09-21-2012
11:39 AM
|
0
|
0
|
1068
|
|
POST
|
I agree that DDP is limited in terms of query capabilities (and other capabilities as well). It was designed with a simple interface but it can be further extended via arcpy.mapping. I have to disagree with the below statement that arcpy isn't far enough along. For example, a page definition in arcpy.mapping is simply a layer's definition query. See recent post on this topic: http://forums.arcgis.com/threads/67271 Some thoughts concerning this application idea. 1) One of the basic rules in setting up DDP is that each DDP index feature have a unique value. In this case, the values are not unique so how does DDP know what feature to go to? 2) If the values are not unique then I don't think I would use that field. I would probably use something like OID instead and then generate my own parcel parcer via arcpy.mapping. For example, I would build a script tool that displayed multiple field inputs (the first being required, and all the other being optional). In this example, the first field would be parcel id. If the value is 0, then I would use a second field to further isolate my selection (perhaps owner name), etc. Using the scripting logic a query would be built against the database. Based on the query, internally, I would return the proper OID and automagically set the DDP to match that OID. 2) All of #2 but do it in a Python addin rather than a script tool. To summarize, this becomes a very custom application which would never be a one-size-fits-all type of query in the out-of-the-box DDP. This is partially why arcpy.mapping was made avaiable (I say partially because it can do a whole lot of other stuff too). Jeff PS - ok, ok, I know some of you are going to flame me for this response. 🙂
... View more
09-21-2012
10:55 AM
|
0
|
0
|
1016
|
|
POST
|
Redirecting the active MXD app is not possible with arcpy.mapping. It was not designed to do this. Its purpose was to connect to existing, pre-authored MXDs. For similar reasons, you can't change page size, orientation, etc. Jeff
... View more
09-21-2012
10:29 AM
|
0
|
0
|
4087
|
|
POST
|
Thanks for providing the data/scipts. I can reproduce the issue. Layer.symbology.reclassify() is resetting both shape and outline properties but it is maintaining the colorramp colors. For example, if the symbol loaded from UpdateLayer is a square with with NO outline color, the symbol gets changed to the default circle and the outline color/thickness returns to default when .reclassify() is applied. The only work around I can think of is to NOT use .reclassify() and instead determine the breaks and labels using some scripting logic and then apply those values to the renderer via .classBreakValues and .classBreakLabels. We will investigate this further and try to make a fix available as soon as possible in a service pack. Thanks, Jeff
... View more
09-20-2012
12:43 PM
|
0
|
0
|
3111
|
|
POST
|
Could you send me a map package, so I can give it a try? Include the script and the layer file. [email protected] Jeff
... View more
09-20-2012
08:48 AM
|
0
|
0
|
3111
|
|
POST
|
Hello Ryan, What a great question and something I never considered until just now. I think the only way to test this is to use the Layer.longName property. I hacked together some code below. I have a function called "IsLayerReallyVisible". I split the longName into a list (of each layer name in the group layer path) and then test each individual layer name. If I find a False, I immediately return that value and exit the function. import arcpy def IsLayerReallyVisible(mxd, layer): lyrNameList = layer.longName.split("\\") for lyrName in lyrNameList: lyr = arcpy.mapping.ListLayers(mxd, lyrName)[0] if not lyr.visible: return False return True mxd = arcpy.mapping.MapDocument("current") lyr = arcpy.mapping.ListLayers(mxd, "US_States")[0] print IsLayerReallyVisible(mxd, lyr) I'd like to learn more about your workflows and if you think it would be necessary to add an enhancement to the API to make this a little more straight forward - or is the code above good enough. Jeff
... View more
09-20-2012
08:35 AM
|
0
|
0
|
1534
|
|
POST
|
Page Definition Queries are only available in the UI if you are using DDP but that is not to say you can't accomplish the same thing outside of the UI. With arcpy.mapping you would simply set a .definitionQuery on each appropriate layer. For example, let us say I add two State layers to a dataframe/map. The bottom layer is the index layer and the top layer is a masking layer. I'm using the masking layer to mask away anything outside the current index feature. I set the top layer to be solid white. In the UI, I would set the Page Definition Query to Not Match the index field state name. In arcpy, I would use code similar to: import arcpy mxd = arcpy.mapping.MapDocument("CURRENT") maskLyr = arcpy.mapping.ListLayers(mxd, "Masking Layer")[0] #Layer to apply def query. for pageNum in range(1, mxd.dataDrivenPages.pageCount + 1): mxd.dataDrivenPages.currentPageID = pageNum stateName = mxd.dataDrivenPages.pageRow.STATE_NAME #Get field used in dynamic query maskLyr.definitionQuery = "\"STATE_NAME\" <> '" + stateName + "'" #apply dynamic query arcpy.mapping.ExportToPDF(mxd, r"C:\Temp\\" + stateName + ".pdf") del mxd Hope this helps, Jeff
... View more
09-20-2012
08:06 AM
|
0
|
0
|
1309
|
|
POST
|
I'd like to learn more about your workflow. Would it be possible to include screenshots? The layer that you are using as your source layer must have the correct classification method. You are not able to change classification methods using arcpy.mapping. Reclassify essentially refreshes the layer against the source data (this is especially useful when using UpdateLayer). If your classification methods are different I would expect things to get "clobbered". You can always programatically control the breaks, labels, etc using arcpy.mapping. Again, it would be nice to see more of what you are trying to do. Jeff
... View more
09-19-2012
08:03 AM
|
0
|
0
|
3111
|
|
POST
|
Here are two friendly forum post reminders: 1) this new question should be a new thread. Try not to ask new questions within a thread because it makes it difficult for other users to search and learn from. 2) don't address the questions directly to a single person. They are for the community to read and respond to. Granted I do check this forum every day but I am allowed to take time off. 🙂 Concerning your new issue. It could be that you have raster layers/graphics in your mxd. When graphics are involved, all layers below the highest graphic layer are rasterized. If there is a raster picture in the layout, it too will cause everything to rasterize. Jeff
... View more
09-12-2012
06:15 AM
|
0
|
0
|
2295
|
|
POST
|
We do not have an arcpy.mapping Layer property that allows us to determine/set this. UpdateLayer will apply the symbology however it is persisted in the source layer (i.e., collapse yes/no). In your case, why are you using UpdateLayer? Are you just trying to replace data sources or are you also changing out symbology? Jeff
... View more
09-11-2012
07:50 AM
|
0
|
0
|
2783
|
|
POST
|
We'll need more specifics in order to evalute this issue. Its the "# do some processing here" part that I'd like to see. Is there any way you can provide more of the script? Also, what version of the software are you using. Thanks, Jeff
... View more
09-11-2012
07:35 AM
|
0
|
0
|
1151
|
|
POST
|
Craig, I modified a bunch of things and I made some slight changes to work with my data. See the code below. 1) Moved mxd variable out of loop. It only needs to be referenced once. 2) I got rid of your "i" iterator lines. Your for loop was good enough. 3) I modified your queryStr variable so it works with dyanmic data. Because you are working with a fGDB, placing double quotes around double quotes requires using an escape character. There are other methods. 4) I fixed your for lyr loop. It was using "regional" as a layer name search and you were also using [0] - that won't work. 5a) Your if lyr.name == was looking for a workspace value, it needs to be the layer name the way it appears in the TOC. 5b) You'll want to add your additoinal searches since I only used one layer 6) arcpy.RefreshActiveView() wasn't really needed. import arcpy fc = r"C:\Temp\Test.gdb\SrcR" field = "NAME" # Field of interest values = [row[0] for row in arcpy.da.SearchCursor(fc, (field))] uniqueValues = sorted(set(values)) mxd = arcpy.mapping.MapDocument(r"C:\Temp\defQuery.mxd") for value in uniqueValues: queryStr = "\"" + field + "\" = '" + str(value) + "'" df = arcpy.mapping.ListDataFrames(mxd, "Regional")[0] for lyr in arcpy.mapping.ListLayers(mxd, "", df): if lyr.name == "SrcR": lyr.definitionQuery = queryStr arcpy.mapping.ExportToPDF(mxd, r"C:\Temp" + "\\" + value + ".pdf") # Output individual PDF pages del mxd I hope this helps, Jeff
... View more
09-11-2012
07:24 AM
|
0
|
0
|
2295
|
|
POST
|
I installed 10.0 on a new machine, downloaded the zip and it all just worked. I'm not sure why things are not working for you. Could it be a file permissions issue, the location of your copy has spaces in the path, etc. Over 100 people have downloaded this and there have been no other reports. Jeff
... View more
09-10-2012
08:44 AM
|
0
|
0
|
2031
|
|
POST
|
A new feature dataset or a new GDB? Feature classes with the same name can't exist in two different feature datasets in the same GDB. I.e., all feature classes in a GDB must have a unique name. Jeff
... View more
09-10-2012
05:59 AM
|
0
|
0
|
2146
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 06-05-2025 11:20 AM | |
| 3 | 06-05-2025 09:21 AM | |
| 1 | 05-14-2025 01:19 PM | |
| 2 | 04-24-2025 07:54 AM | |
| 1 | 03-15-2025 07:19 PM |
| Online Status |
Offline
|
| Date Last Visited |
06-23-2026
10:29 AM
|