Created
July 9, 2020 03:54
-
-
Save rdapaz/72dbdad6499e95058e7a94200f76573f to your computer and use it in GitHub Desktop.
Equidistant Guides in Visio (Using Python Script)
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'<file and path>.vsd' | |
dwg = vsApp.Documents.Open(path) | |
# TODO this range gets changed depending on the guides which need to be dragged and dropped on the sheet | |
guides = [f'Sheet.{x}' for x in range(1474, 1492)] | |
print(guides) | |
print(dwg.Pages('<TheSheet>').Name) | |
refShape = 'REFGUIDE' | |
for idx, guide in enumerate(guides, 1): | |
for shp in dwg.Pages('<TheSheet>').Shapes: | |
if shp.Name == guide: | |
print(shp.Name) | |
try: | |
shp.Cells("PinX").Formula = f"GUARD({refShape}!PinX + {0.169*idx}m)" | |
except: | |
pass | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment