IDEA
|
Yes please. We need this function. Can it be option of the attribute table pane to sync the tables shown with the active map?
... View more
12-09-2022
03:49 PM
|
0
|
0
|
525
|
POST
|
No, haven't solved this entirely. The easiest workaround was to go back to ArcMap.
... View more
02-24-2020
06:49 PM
|
0
|
1
|
5174
|
POST
|
Let's say I need to add a new statement to an existing Def query to all layers in a group which would like like something like this: aprx = arcpy.mp.ArcGISProject("CURRENT")
m = aprx.listMaps("Map")[0]
for lyr in m.listLayers():
if lyr.supports ("longname"):
parent = lyr.longName.split('\\')
if parent [0] == "Group":
print (lyr.longName)
if lyr.supports("DEFINITIONQUERY"):
oldDefQuery = lyr.definitionQuery
lyr.definitionQuery = None
newDefQuery = oldDefQuery + " CODE = 0"
lyr.definitionQuery = newDefQuery What happens after running the script is that the old definition query becomes inactive and the newly created query is added and becomes active. However they both remain the same query name and seem to clash with each other so that no feature pass through the query (don't mind the fieldnames): There seem to be no detailed explanation on the definitionQuery property at Layer—ArcPy | ArcGIS Desktop So the questions are: How to achieve this to work properly: Modify the existing one? - This used to work in ArcMAP Remove the initial query completely and place a new modified query? Is there any documentation on how to control the functions in the definition query tab on layer properties via Arcpy?? Thanks heaps!
... View more
10-08-2019
07:36 PM
|
0
|
10
|
6252
|
POST
|
Was this resolved? I am having the same issue when exporting to .AI using arcpy on 10.4.1 I don't rotate the data frame but I have a few layers displayed using rotation field. When exporting through standard way (File>Export>...) everything works fine. But when I export using arcpy the symbols end up un-rotated. MXD: : AI file: The code I am using: import arcpy, os
MapMainFolder = r"Z:\Workspace" # topmost folder
AIoutLoc = r"J:\CURRENT PROJECTS"
for (root, dirs, files) in os.walk (MapMainFolder):
for fileName in files:
if os.path.splitext (fileName)[1] == ".mxd":
arcpy.AddMessage (fileName)
fullPath = os.path.join (root, fileName)
mxd = arcpy.mapping.MapDocument (fullPath)
print fileName
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
#ungoup layers
for lyr in arcpy.mapping.ListLayers(mxd, "*", df):
depth = len(lyr.longName.split("\\"))
if depth == 1:
refLayer = lyr
elif depth == 2:
moveLayer = lyr
arcpy.mapping.MoveLayer(df, refLayer, moveLayer, "BEFORE")
arcpy.RefreshTOC()
#export AI
ai = fileName.replace (".mxd",".ai")
AIpath = os.path.join (AIoutLoc,ai)
arcpy.AddMessage ("Exporting " + ai)
arcpy.mapping.ExportToAI(mxd,AIpath,"PAGE_LAYOUT",0,0, resolution=300, image_quality="BEST", convert_markers="true")
... View more
04-11-2018
09:20 PM
|
0
|
1
|
711
|
POST
|
Thanks Terry Giles. It works but it ungroups everything. I forgot to mention there were some subgroups in the topmost group layer and they needed to remain grouped. Anyway the other solution below works.
... View more
10-23-2017
05:00 PM
|
0
|
0
|
2069
|
POST
|
This is it bixb0012!! Works flawlessly. Thanks a lot! Indeed I forgot to add there are sub-grouplayers within the top group layer with layer properties( transparency etc.) and they need to remain in groups. Basically I just needed to ungroup only the topmost group. The TOC looks like this: Topmost Group Layer1 Group (has group layer properties) Layer2 Layer3 ... Layer4 ... And I need to have: Layer1 Group (has group layer properties) Layer2 Layer3 ... Layer4 ... Anyway your solution works and it remains the layer properties as they were in the subgroups. Elegant and simple. Cheers! Jan
... View more
10-23-2017
04:52 PM
|
0
|
0
|
2069
|
POST
|
Thanks Randy, This seem to work. However I forgot to add there are indeed sub-grouplayers within the top group layer with group settings ( transparency etc.) and they need to remain in groups. Basically I just need to ungroup only the topmost group. The TOC looks like this: Topmost Group Layer1 Group (has group layer properties) Layer2 Layer3 ... Layer4 ... And I need to have: Layer1 Group (has group layer properties) Layer2 Layer3 ... Layer4 ... Your script works perfect but I need to keep the subgroup settings intact. I realise that might be a limiting factor. Cheers!!
... View more
10-23-2017
04:27 PM
|
0
|
0
|
2069
|
POST
|
Hi All, I've been trying to ungroup a group layer in TOC using Arcpy with no luck. There is no such function in arcpy so the approach I am trying to do is moving layer by layer out of the group and place them all on top of TOC. However I can't get the loop through layers working. The mxd structure is: Topmost Group Layer1 Layer2 Layer3 ... And I want to have: Layer1 Layer2 Layer3 ... The code below only moves the last layer from the TopGroup: import arcpy, os
MapMainFolder = r"Z:\Workspace" # topmost folder
for (root, dirs, files) in os.walk (MapMainFolder):
for fileName in files:
if os.path.splitext (fileName)[1] == ".mxd":
arcpy.AddMessage (fileName)
fullPath = os.path.join (root, fileName)
mxd = arcpy.mapping.MapDocument (fullPath)
print fileName
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
#Layers to be moved !!! NEEDS TO LOOP through all layers !!!
for lyr in arcpy.mapping.ListLayers(mxd):
if lyr.name != lyr.longName:
moveLayer = lyr
print moveLayer
#Topmost group layer, the content of this group layer should be moved above this layer and the group can remain empty
for lyr in arcpy.mapping.ListLayers(mxd):
if lyr.name == lyr.longName:
refLayer = lyr
print refLayer
arcpy.mapping.MoveLayer(df, refLayer, moveLayer, "BEFORE")
arcpy.RefreshTOC()
arcpy.RefreshActiveView()
mxd.save() Anyone has any idea on: how to loop through the layer list? how use a different approach? The reason I need to ungroup the layers is to avoid having all layers rasterized when exporting to an Illustrator file. Thanks for help!
... View more
10-22-2017
08:17 PM
|
1
|
8
|
3287
|
Title | Kudos | Posted |
---|---|---|
1 | 10-22-2017 08:17 PM |
Online Status |
Offline
|
Date Last Visited |
12-09-2022
11:51 PM
|