|
IDEA
|
@asmith_tssw could you share a small snippet of code that demonstrates what the script tool is doing?
Thanks,
Jeff - arcpy.mp and Layout (SDK) teams
... View more
11-14-2024
03:19 PM
|
0
|
0
|
1798
|
|
IDEA
|
@DougBrowning are you working straight text? With straight text, regardless of alignment if you change the string to be something shorter, the text envelope that contains the text will be left aligned since that is the anchor point location. If you change the anchor position to center and then modify the string, it should stay center aligned.
Jeff - arcpy.mp and Layout (SDK) teams.
... View more
11-14-2024
03:17 PM
|
0
|
0
|
1799
|
|
IDEA
|
Thanks again for your idea! This is implemented in ArcGIS Pro 3.4. Go to Your Ideas in ArcGIS Pro 3.4 to see other ideas implemented this release and check out the What's New help to learn about everything that is new and improved in ArcGIS Pro 3.4.
Jeff - Layout (SDK) and arcpy.mp teams
... View more
11-12-2024
09:06 AM
|
0
|
0
|
1986
|
|
POST
|
Try this link: https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic76003.html
Jeff - Layout and arcpy.mp teams
... View more
10-07-2024
07:57 AM
|
0
|
0
|
2196
|
|
POST
|
@AntoinePrince1805
One of the efficiencies of the CIM is also one of its limitations. The CIM mostly persists non-default data to minimize its size and improve performance. So if no alterations are made to default field info, the field info does not appear in the CIM definition.
Try the code below. The trick is to use MakeFeatureLayer which does include the CIM definitions, make alterations and copy the updated CIM information to your target layer.
p = arcpy.mp.ArcGISProject('current')
m = p.listMaps()[0]
lyr = m.listLayers('Provinces')[0]
lyr_cim = lyr.getDefinition('V3')
fList = ["SQKM", "POP2001", "Shape_Length", "Shape_Area"]
#IF NO CIM FIELD DESC INFO IS AVAILBLE
if len(lyr_cim.featureTable.fieldDescriptions) == 0:
print('No CIM Field Info')
#Make temporary layer (which automatically gets CIM field info)
mkLyr = arcpy.management.MakeFeatureLayer(lyr)[0]
mkLyr_cim = mkLyr.getDefinition('V3')
for fd in mkLyr_cim.featureTable.fieldDescriptions:
if fd.fieldName in fList:
fd.numberFormat.roundingOption = "esriRoundNumberOfDecimals"
fd.numberFormat.roundingValue = 0
fd.numberFormat.zeroPad = True
mkLyr.setDefinition(mkLyr_cim)
#Copy CIM information and remove temporary layer
lyr_cim.featureTable.fieldDescriptions = mkLyr_cim.featureTable.fieldDescriptions
lyr.setDefinition(lyr_cim)
m.removeLayer(mkLyr)
Jeff - arcpy.mp and Layout teams
... View more
10-04-2024
08:31 AM
|
1
|
1
|
1773
|
|
IDEA
|
Thank you for your feedback. We hope to incorporate type hints into many more of our classes for the 3.5 release. Jeff - arcpy.mp and Layout teams
... View more
08-29-2024
11:01 AM
|
0
|
0
|
939
|
|
POST
|
@MohamedHassan17 , are you using applySymbologyFromLayer by chance? If so, there are some alternative solutions. If not, we would need a reproducible case. Jeff
... View more
08-12-2024
08:22 AM
|
0
|
2
|
1199
|
|
IDEA
|
This has been hanging around for some time now but this has been possible for many releases with Layer.saveACopy(). Jeff - Layout and arcpy.mp teams
... View more
08-09-2024
02:50 PM
|
0
|
0
|
470
|
|
POST
|
@masa I tried your code on my Pro 3.3 machine, even with V2 and it worked. I would recommend trying on a more current build of Pro. There have been 5 new releases plus many patches since 2.8. Jeff
... View more
08-09-2024
02:25 PM
|
0
|
1
|
1479
|
|
IDEA
|
@SamuelRomero2, I'm not sure if I'm understanding this correctly because this can be scripted using arcpy.mp. Please let us know if the following snippet isn't what you are looking for. import os customPath = r'C:\Temp' p = arcpy.mp.ArcGISProject('current') for lyt in p.listLayouts(): lyt.exportToPAGX(os.path.join(customPath, lyt.name)) Jeff - Layout and arcpy.mp teams
... View more
08-07-2024
09:59 AM
|
0
|
1
|
642
|
|
POST
|
@MK13 Again, this is just a work around but have you tried something like ... import os p = arcpy.mp.ArcGISProject('current') relpath = p.homeFolder m = p.listMaps('Map')[0] for l in m.listLayers(): if l.name == 'GreatLakes': lyr1 = arcpy.mp.LayerFile(os.path.join(relpath, 'GreatLakes.lyrx')).listLayers('GreatLakes')[0] l.symbology = lyr1.symbology #Also copy label classes l_cim = l.getDefinition('V3') lyr1_cim = lyr1.getDefinition('V3') l_cim.labelClasses = lyr1_cim.labelClasses l.setDefinition(l_cim) l.showLabels = True #Just in case they are not visible Jeff
... View more
08-05-2024
02:52 PM
|
1
|
0
|
1721
|
|
POST
|
@masa here is some sample code to at least create the ei_cim.symbol. PointSymbol still needs to be defined if needed. Lines 6-26 below were added. I also altered how I'm finding the locator map frame in the CIM elements list instead of hard coding an index number (line 38-40). p = arcpy.mp.ArcGISProject('current')
lyt = p.listLayouts()[0]
mf = lyt.listElements('MapFrame_Element', 'Main MF')[0]
lyt_cim = lyt.getDefinition('V3')
#Create Polygon Symbol with solid stroke outline and transparenent fill
polyStrokeRGBColor = arcpy.cim.CreateCIMObjectFromClassName('CIMRGBColor', 'V3')
polyStrokeRGBColor.values = [0, 0, 0, 100]
polySymLyr1 = arcpy.cim.CreateCIMObjectFromClassName('CIMSolidStroke', 'V3')
polySymLyr1.capStyle = "Round"
polySymLyr1.joinStyle = "Round"
polySymLyr1.width = 1
polySymLyr1.color = polyStrokeRGBColor
polyFillRGBColor = arcpy.cim.CreateCIMObjectFromClassName('CIMRGBColor', 'V3')
polyFillRGBColor.values = [0, 0, 0, 0]
polySymLyr2 = arcpy.cim.CreateCIMObjectFromClassName('CIMSolidFill', 'V3')
polySymLyr2.color = polyFillRGBColor
polySym = arcpy.cim.CreateCIMObjectFromClassName('CIMPolygonSymbol', 'V3')
polySym.symbolLayers = [polySymLyr1, polySymLyr2]
polySymRef = arcpy.cim.CreateCIMObjectFromClassName('CIMSymbolReference', 'V3')
polySymRef.symbol = polySym
#Create Extent indicator
ei_cim = arcpy.cim.CreateCIMObjectFromClassName('CIMExtentIndicator', 'V3')
ei_cim.sourceMapFrame = mf.name
ei_cim.extentIndicatorType = "Frame"
ei_cim.isVisible = True
ei_cim.name = "extent_indicator"
ei_cim.symbol = polySymRef
#ei_cim.pointSymbol = ptSymRef
for elm in lyt_cim.elements:
if elm.name == 'Locator MF':
elm.extentIndicators.insert(0, ei_cim)
#Set back to layer
lyt.setDefinition(lyt_cim) Jeff
... View more
08-05-2024
01:25 PM
|
0
|
3
|
1528
|
|
POST
|
@masa I believe the issue is that you don't have ei_cim.symbol or ei_cim.pointSymbol defined. It will require much more code to define these because multiple CIM classes are required to construct them from scratch. This is a classic example of where the Layout or MapFrame objects could use a helper function to insert an extent indicator, especially now that new layouts can be created. I would suggest adding an Esri Idea requesting this exact functionality. If you are not creating a layout in your script, it may be a lot easier to modify an already existing extent indicator. Jeff - Layout and arcpy.mp teams. I'll see if I can come up with a CIM solution later.
... View more
08-05-2024
12:05 PM
|
0
|
0
|
1528
|
|
POST
|
Thanks @MK13 for bringing this to my attention. This is something we are looking into and need to coordinate with the core GP/arcpy team. Here is a brief explanation and a couple of possible work-arounds. ApplySymbologyFromLayer is a core GP/arcpy method. It runs on the GP thread which includes includes GP dialogs, models, and script tools. The GP thread provides isolation so the application (main thread) can continue to run. Arcpy.mp was designed to work with the application objects and also runs on the main thread. When using a script tool, its important to hook the results back to the main thread and this can be done using the technique mentioned by @TanGnar above. import os p = arcpy.mp.ArcGISProject('current') relpath = p.homeFolder lyr = arcpy.GetParameter(0) if lyr.name == ‘GreatLakes’: lyrx = os.path.join(relpath, 'GreatLakes.lyrx’) arcpy.management.ApplySymbologyFromLayer(lyr, lyrx) arcpy.SetParameter(1, lyr) Another alternative is to use an all arcpy.mp solution where you "copy" the symbology using this technique. import os p = arcpy.mp.ArcGISProject('current') relpath = p.homeFolder for lyr in p.listMaps(‘Map’).listLayers(): if lyr.name == ‘GreatLakes’: lyrx = os.path.join(relpath, 'GreatLakes.lyrx’) lyrx_lyr = lyrx.listLayers(‘GreatLakes’)[0] lyr.symbology = lyrx_lyr.symbology And at Pro 3.4 we hope to introduce a new (feature) Layer.pasteProperties(source_layer, properties) method that allows you copy existing layer properties from a source layer where it defaults to all default properties OR you can specify keywords such as symbology, or definition queries, field aliases, or pop-ups, etc, Jeff - Layout and arcpy.mp teams
... View more
08-05-2024
09:13 AM
|
1
|
1
|
1732
|
|
POST
|
@MK13 there is not a way to activate a map frame from arcpy.mp and we don't have plans to provide that capability but I would like to hear more about your scenario. We have a few exceptions (e.g., opening and closing views) but try to provide functions that can work with scripts in the application and stand alone scripts outside the application. Activating a map frame would only work in the application. The .NET SDK provides finer grained capabilities to perform operations like this and its main focus with Add-ins is to work within the contest of the application. Jeff - Layout and arcpy.mp teams
... View more
07-31-2024
07:11 AM
|
1
|
0
|
821
|
| 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
|