POST
|
That is indeed what I was missing. Thank you! For anyone else running into a similar issue in the future, I took Szym's suggestion and combined it with a ModifyRelateProperties script that is within the ESRI supplied CIM_Examples_Pro25_v1 found here: https://www.arcgis.com/home/item.html?id=8772f61319584882bb697ba003030636. Here's my working code: currentDb = QA_SDE
outputDb = Prod_SDE
currentEnv = QA_RegisteredDir
outputEnv = Prod_RegisteredDir
inputAprx = QA_Aprx
targetAprx = Prod_Aprx
aprx = arcpy.mp.ArcGISProject(inputAprx)
maps = aprx.listMaps()
for map in maps:
layers = map.listLayers()
for layer in layers:
if not layer.supports('dataSource'):
continue
elif currentDb in layer.dataSource:
newProps = layer.connectionProperties
oldProps = layer.connectionProperties
newProps['connection_info']['db_connection_properties'] = outputDb
newProps['connection_info']['instance'] = 'sde:sqlserver:' + outputDb
newProps['connection_info']['server'] = outputDb
newProps['connection_info']['authentication_mode'] = 'OSA'
layer.updateConnectionProperties(current_connection_info = oldProps, new_connection_info = newProps)
if 'relates' in layer.connectionProperties:
lyrCIM = layer.getDefinition('V2')
dc = lyrCIM.featureTable.relates[0].dataConnection
dc.workspaceConnectionString = dc.workspaceConnectionString.replace(currentDb, outputDb)
layer.setDefinition(lyrCIM)
elif currentEnv in layer.dataSource:
layer.updateConnectionProperties(current_connection_info = currentEnv, new_connection_info = outputEnv)
aprx.saveACopy(targetAprx)
... View more
10-16-2023
01:52 PM
|
1
|
0
|
325
|
POST
|
In ArcPy 3.7 (ArcPro 2.9 environment), I am looking to promote an Aprx from one environment to another, changing datasets accordingly. I am using layer.updateConnectionProperties to switch from QA SDE layers to Prod SDE layers. This works as expected for the layers, themselves, but I cannot get the related table (also SDE based) to also update to Prod data sources. auto_update_joins_and_relates doesn't work, nor does spelling out the new environmental parameters by updating the connection properties dictionary. currentDb = QA_SDE
outputDb = Prod_SDE
currentEnv = QA_RegisteredDir
outputEnv = Prod_RegisteredDir
inputAprx = QA_Aprx
targetAprx = Prod_Aprx
aprx = arcpy.mp.ArcGISProject(inputAprx)
maps = aprx.listMaps()
for map in maps:
layers = map.listLayers()
for layer in layers:
if not layer.supports('dataSource'):
continue
elif currentDb in layer.dataSource:
newProps = layer.connectionProperties
oldProps = layer.connectionProperties
newProps['connection_info']['db_connection_properties'] = outputDb
newProps['connection_info']['instance'] = 'sde:sqlserver:' + outputDb
newProps['connection_info']['server'] = outputDb
newProps['connection_info']['authentication_mode'] = 'OSA'
if 'relates' in layer.connectionProperties:
if isinstance(newProps['relates'], list):
newProps['relates'][0]['connection']['connection_info']['db_connection_properties'] = outputDb
newProps['relates'][0]['connection']['connection_info']['instance'] = 'sde:sqlserver:' + outputDb
newProps['relates'][0]['connection']['connection_info']['server'] = outputDb
newProps['relates'][0]['connection']['connection_info']['authentication_mode'] = 'OSA'
layer.updateConnectionProperties(current_connection_info = oldProps, new_connection_info = newProps, auto_update_joins_and_relates = True)
elif currentEnv in layer.dataSource:
layer.updateConnectionProperties(current_connection_info = currentEnv, new_connection_info = outputEnv)
aprx.saveACopy(targetAprx) When run, newProps dictionary updates accordingly to reflect the Prod sourced related table. However, when updateConnectionProperties is run, the layer source is in Prod but the relate is still QA sourced. This behavior occurs both when auto_update_joins_and_relates is set to True and to False. What am I missing here?
... View more
10-10-2023
02:49 PM
|
1
|
2
|
443
|
POST
|
Friendly GeoNet, I have an Arcpy script that creates an MXD and subsequently exports that MXD as an MPK. When I run the script, the output MPK file is 8 MB in size. If I open that same MXD in ArcGIS Desktop and package the map manually using the defaults. the output MPK file is 2 MB. The code I am using to package is: arcpy.PackageMap_management(mpktarget, output, 'PRESERVE', 'PRESERVE_ARCSDE', 'DISPLAY') My question is: What are the best settings to use in Arcpy to replicate the Share As Map Package manual tool in ArcGIS Desktop? If my code above is indeed the correct settings, where should I look to trim that additional 6 MB from the script output?
... View more
07-22-2020
10:49 AM
|
1
|
2
|
447
|
Title | Kudos | Posted |
---|---|---|
1 | 10-16-2023 01:52 PM | |
1 | 10-10-2023 02:49 PM | |
1 | 07-22-2020 10:49 AM |
Online Status |
Offline
|
Date Last Visited |
10-16-2023
09:54 PM
|