Skip to content

Instantly share code, notes, and snippets.

@rdapaz
Created July 9, 2020 03:54
Show Gist options
  • Save rdapaz/72dbdad6499e95058e7a94200f76573f to your computer and use it in GitHub Desktop.
Save rdapaz/72dbdad6499e95058e7a94200f76573f to your computer and use it in GitHub Desktop.
Equidistant Guides in Visio (Using Python Script)
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