|
POST
|
@RoshanPalikhe1 , have you tried using Layer.pasteProperties? It was made available with Pro 3.4. Layer—ArcGIS Pro | Documentation The following example will reference the symbology properties of a source layer in a layer file (see Note below) and apply those properties to the layer of interest. You can paste all layer properties or choose specific layer properties to paste. With the arcpy.mp method, you can provide a list of different properties in case you don't want all but want multiple properties. In the example below two properties are being pasted. It works similarly to the UI context options and includes the same limits (e.g., geometries must match). p = arcpy.mp.ArcGISProject('current')
m = p.listMaps('Yosemite National Park')[0]
lyr = m.listLayers('Campgrounds')[0]
lyrFile = arcpy.mp.LayerFile(r"C:\Projects\ProjectData\LYRXs\Campgrounds.lyrx")
sourceLyr = lyrFile.listLayers('Campgrounds')[0]
lyr.pasteProperties(sourceLyr, ['SYMBOLOGY', 'VISIBILITY_RANGE']) NOTE: the source layer is not limited to coming from a layer file, it can be a layer in a map in the same project, or different projects, etc. Jeff - arcpy.mp team
... View more
2 weeks ago
|
0
|
0
|
347
|
|
IDEA
|
This is a very old ArcMap idea that is being closed because these capabilities will not be added to ArcMap and were added at ArcGIS Pro 3.4. ArcGISProject—ArcGIS Pro | Documentation Has: createGraphicElement(), createGroupElement, createLayout, createPictureElement, createPredefinedGraphicElements, and createTextElements. Layout—ArcGIS Pro | Documentation Has: createMapFrame(), createMapSurroundElement(), createTableFrameElement() Jeff - arcpy.mp Team
... View more
03-09-2026
12:05 PM
|
0
|
0
|
126
|
|
IDEA
|
Closing this ArcMap issue. There is a solution in ArcGIS Pro. We made great improvements in Pro concerning definition queries (DQs). Pro layers now support multiple DQs and our API allows you to not only change a DQ (like ArcMap could), but also add multiple DQs and set the active DQ. Much of this is mentioned in the help via the following Layer members Layer.definitionQuery - in ArcMap and Pro Layer.listDefinitionQueries ({wildcard}) - new in Pro Layer.updateDefinitionQueries (definitionQueries) - new in Pro Layer—ArcGIS Pro | Documentation NOTE - Pro does NOT have an UpdateLayer. Our model has changed quite a bit. There is a similar, but different method in Pro: Layer.pasteProperties (which has an option to paste all properties or limited collections, including DQs). The list of options is in the Layer help link above. I hope this helps, Jeff
... View more
03-09-2026
10:12 AM
|
0
|
0
|
182
|
|
IDEA
|
@Pukawai The original author of this idea was happy with the solution so we marked it accordingly. We also have ArcGISProject.closeViews() so you can close your views, then open the specific view using openView(). OpenView will automatically activate the view. We have NO way of referencing existing views because individual instances are not uniquely named. Closing views and (re)opening ensures you get the active view you want. At 3.7 we enhanced closeViews() to include a wildcard parameter so rather than closing all map views, for example, you can close views that only reference a specific map. See: arcpy.mp Map and Layout isOpen - Esri Community The major focus of arcpy.mp is for ArcGIS Project automation, not application development. There are many scenarios where the .Net SDK is a better solution for application development. I hope this helps, Jeff - arcpy.mp team
... View more
03-06-2026
03:26 PM
|
0
|
0
|
480
|
|
IDEA
|
This is a very old idea and is available in both ArcMap and Pro. ArcMap and Pro, the older style ExportToXXX methods have a property called {clip_to_elements} For example, the Layout class: Layout—ArcGIS Pro | Documentation In Pro we have a newer style export format objects, and a similar property called clipToElements is available to the export format when exporting a layout. For example, PDFFormat: PDFFormat—ArcGIS Pro | Documentation Jeff - arcpy.mp team
... View more
03-06-2026
12:57 PM
|
0
|
0
|
171
|
|
IDEA
|
This should have been closed, at least for those that are using ArcGIS Pro. The arcpy.mp API offers a number of ways of creating and managing labelClasses. LabelClass—ArcGIS Pro | Documentation Properties not directly exposed can be modified via Python CIM Access. Jeff - arcpy.mp team
... View more
03-06-2026
12:46 PM
|
0
|
0
|
507
|
|
IDEA
|
This is being planned for the 3.8 release. Jeff - arcpy.mp team
... View more
03-06-2026
12:39 PM
|
0
|
0
|
408
|
|
IDEA
|
This is planned for the upcoming 3.7 release. The function is ... arcpy.mp.CreateArcGISProject(project_path, project_name, {create_parent_folder}, {home_folder}, {default_database}, {default_toolbox})
... View more
03-06-2026
11:22 AM
|
0
|
0
|
303
|
|
DOC
|
@MarcoBoeringa I jumped on this as soon as it was brought to my attention. I didn't try the other blocks of code but they were using variables and settings that had missing context, therefore, I focused on your comment concerning the use of a dict to set label class CIM properties. Testing layer files is easy enough and I will try that but your comment "there is a *lot* more going on" could be the missing pieces. We can't debug until we can reproduce the issue.
... View more
12-04-2025
06:52 AM
|
0
|
0
|
12662
|
|
DOC
|
@MarcoBoeringa I did the best I could to simulate your scenario without having your data or complete scripts. I can NOT reproduce. Everything works on the background or foreground threads. I can talk with the labeling team to see if the smoking gun you suggest could have been caused by changes made during 3.6 development. Here is the script ran from a script tool. It ran against a single polygon feature layer with 10 label classes. I only set the priorities for half of them and set the other half using an incremented value. import arcpy
if __name__ == "__main__":
p = arcpy.mp.ArcGISProject('current')
m = p.listMaps('Map')[0]
l = m.listLayers('States_WithRegions')[0]
l_cim = l.getDefinition('V3')
labelPriorityByLayerDict = {'New England' : 1, 'Pacific': 2, 'Mountain' : 3, 'South Atlantic' : 4, 'West North Central' :5}
i = 6
for cimLabelClass in l_cim.labelClasses:
if type(cimLabelClass).__name__ == "CIMLabelClass":
try:
if cimLabelClass.priority == -1:
if cimLabelClass.name in labelPriorityByLayerDict:
before = cimLabelClass.priority
cimLabelClass.priority = labelPriorityByLayerDict[cimLabelClass.name]
arcpy.AddMessage(f'Changing {cimLabelClass.name} from {str(before)} to {cimLabelClass.priority}')
else:
before = cimLabelClass.priority
cimLabelClass.priority = i
arcpy.AddMessage(f'Changing {cimLabelClass.name} from {str(before)} to {cimLabelClass.priority}')
i += 1
except:
arcpy.AddWarning("*** WARNING ***: Failed to set label ranking")
pass
l.setDefinition(l_cim) It would be really helpful to know if the script above fails for you against your data after making the necessary changes. Jeff - arcpy.mp Team
... View more
12-03-2025
10:25 PM
|
0
|
0
|
12727
|
|
DOC
|
@MarcoBoeringa I appreciate your effort reporting your findings but I don't have enough to reproduce. The snippet of code you most recently provided is not complete. I prefer not to guess. I modified the original code you provided to GET the labelclass.name and it is returning values as expected. The regression could be caused by a combination of events. Is there any way you can provide a more complete, simplified and reproducible ppkx with the script tool. My email is jbarrette@esri.com Jeff - arcpy.mp Team
... View more
12-03-2025
09:09 AM
|
0
|
0
|
12761
|
|
DOC
|
@MarcoBoeringa , I'm on the arcpy.mp team and tested your label class CIM edits / Foreground scenario and was NOT able to reproduce on Win 11. I even tried in on a Win10 machine this morning. I tried old projects that had tbx files and a new 3.6 project with atbx files. Each project has a map with a feature layer with multiple label classes. Each label class had a SQL Query that shows state names for different regions. The following code is part of a script tool and ran fine in all cases in the background and in the foreground. I think its identical to your script unless you have more lines that might be part of the issue. import arcpy
if __name__ == "__main__":
p = arcpy.mp.ArcGISProject('current')
m = p.listMaps('Map')[0]
l = m.listLayers('States_WithRegions')[0]
l_cim = l.getDefinition('V3')
i = 1
for cimLabelClass in l_cim.labelClasses:
if type(cimLabelClass).__name__ == "CIMLabelClass":
try:
#cimLabelClass.priority = i
arcpy.AddMessage(cimLabelClass.priority)
except:
arcpy.AddWarning("*** WARNING ***: Failed to set label ranking")
pass
i += 1
l.setDefinition(l_cim) If you run exactly this code, you still see the issue? Can you think of anything special about your layer, the label classes, etc, that could be unique. Jeff - arcpy.mp team
... View more
12-02-2025
11:35 AM
|
0
|
0
|
12838
|
|
POST
|
I know this is a really old post but I was going through some old emails, etc and came across this thread. I've helped people address this issue (differently than AlterField) and want to paste that code here as an option for people to try. Basically, if there are NO field descriptions (e.g., a layer was just added), then another option is to use MakeFeatureLayer. The MakeFeatureLayer result has the CIM properties. You make the changes and than copy those changes back to the original layer. There are pre3.4 and 3.4 and beyond options. def updateCIMFields(l, cimLyr):
fList = ["SQKM", "POP2001", "Shape_Length", "Shape_Area"]
for fd in cimLyr.featureTable.fieldDescriptions:
if fd.fieldName in fList:
fd.numberFormat.roundingOption = "esriRoundNumberOfDecimals"
fd.numberFormat.roundingValue = 0
fd.numberFormat.zeroPad = True
fd.numberFormat.useSeparator = True
l.setDefinition(cimLyr)
return cimLyr
p = arcpy.mp.ArcGISProject('current')
m = p.listMaps()[0]
lyr = m.listLayers('Provinces')[0]
lyr_cim = lyr.getDefinition('V3')
if len(lyr_cim.featureTable.fieldDescriptions) == 0: #NO CIM field info present
print('No CIM Field Info')
mkLyr = arcpy.management.MakeFeatureLayer(lyr)[0]
mkLyr_cim = mkLyr.getDefinition('V3')
mkLyr_cim = updateCIMFields(mkLyr, mkLyr_cim)
#Copy CIM information and remove temporary layer
#lyr_cim.featureTable.fieldDescriptions = mkLyr_cim.featureTable.fieldDescriptions ###for 3.3 and prior
#lyr.setDefinition(lyr_cim) ###for 3.3 and prior
lyr.pasteProperties(mkLyr, 'FIELD_PROPERTIES') ###for 3.4 and prior
m.removeLayer(mkLyr)
else: #CIM field info present
print('CIM Field Info Pre-Exists')
lyr_cim = updateCIMFields(lyr, lyr_cim)
lyr.setDefinition(lyr_cim) Jeff - arcpy.mp Team
... View more
12-01-2025
08:55 PM
|
0
|
0
|
556
|
|
IDEA
|
@Jeff-Reinhart thanks for your feedback! I'd like to get additional feedback if possible. First, anything that involves working with views via arcpy.mp, it is documented that these members only work for scripts that run within the application (in-process). "Views" really don't exist when referencing a project by path (out-of-process). Given that, we really try to limit the number of in-process only properties and methods. Our main focus is automation and less application customization but we recognize the needs. Second, currently we have ArcGISProject.closeViews() that takes an enum of project item types (i.e., maps, layouts, and reports). So in your "My Layout" example you could have something like: p = arcpy.mp.ArcGISProject("CURRENT")
lyt = p.listLayouts('My Layout')[0]
p.closeViews('LAYOUT') #This closes all layout views
lyt.openView() #This opens AND activates your view One of the limitations, in this example, is it closes all layout views, 'My Layout', 'Your Layout' 'Everybodys Layout' etc. Probably more of an issue with Map items. But what if we extended closeViews() to include a wildcard filter: p.closeViews('LAYOUT', wildcard='My Layout') #This would close any views specific to My Layout The above would close all instances of My Layout but then your would call openView to open AND activate it. A possible problem with isOpen is the layout may be open but it might NOT be active. That would require we add additional in-process only methods like .makeActive, which again, we would like to avoid.
... View more
11-21-2025
11:43 AM
|
0
|
0
|
682
|
| 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 |
a week ago
|