Created
September 24, 2020 06:46
-
-
Save rdapaz/e472eae36adce272dc8d2314a460d2bf to your computer and use it in GitHub Desktop.
Rename Visio Objects
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import win32com.client as c | |
vsApp = c.gencache.EnsureDispatch('Visio.Application') | |
vsApp.Visible = True | |
path = r'https://woodsideenergy-my.sharepoint.com/personal/ricardo_dapaz_woodside_com_au/Documents/Desktop/Compass Documents/XA0000DJ0020.0009 (RDP).vsd' | |
dwg = vsApp.Documents.Open(path) | |
pge = dwg.Pages('CPMS CER, FAR 1&2') | |
nodes = { | |
'DESC.1': 'CERDAS1', | |
'DESC.2': 'CEREWS1', | |
'DESC.3': 'CEREWS2', | |
'DESC.4': 'CEREWS3', | |
'DESC.5': 'CERTC1', | |
'DESC.6': 'CVM', | |
'DESC.7': 'FAR1CMM1', | |
'DESC.8': 'FAR1CMM2', | |
'DESC.9': 'FAR1CMM3', | |
'DESC.10': 'FAR1CMM4', | |
'DESC.11': 'FAR1CMM5', | |
'DESC.12': 'FAR1OPC2', | |
'DESC.13': 'FAR1PC', | |
'DESC.14': 'FAR2CMM1', | |
'DESC.15': 'FAR2CMM2', | |
'DESC.16': 'FAR2CMM3', | |
'DESC.17': 'FAR2CMM4', | |
'DESC.18': 'FAR3CMM1', | |
'DESC.19': 'FAR3CMM2' | |
} | |
for shp in pge.Shapes: | |
if shp.Name.startswith('DESC') and shp.Name in nodes: | |
shp.Text = nodes[shp.Name] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment