Last active
July 9, 2018 00:24
-
-
Save simonmcconnell/b246b2ea04cc0b49536b4e15c5925922 to your computer and use it in GitHub Desktop.
Citect Graphics Builder Automation with Python
This file contains 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
# Citect Graphics Builder Automation with Python | |
# | |
# the object name was discovered from the file created by running PythonWin > Tools > COM Makepy utility. | |
# | |
# pip install -U pywin32 | |
import win32com.client | |
# this seems to attach itself to an already running process also | |
try: | |
gb = win32com.client.Dispatch("GraphicsBuilder.Application.6.1") | |
except: | |
print("Failed to open Graphics Builder") | |
try: | |
project = "Example" | |
page = "Genies" | |
gb.PageOpen(project, page) | |
except: | |
print(f"Failed to open {project}/{page}") | |
# if Citect is already open: | |
try: | |
gb = win32com.client.GetObject(Class="GraphicsBuilder.Application.6.1") | |
except: | |
print("Failed to attach to Graphics Builder process - is it running?") | |
try: | |
project = "Example" | |
page = "Alarm" | |
gb.PageOpen(project, page) | |
except: | |
print(f"Failed to open {project}/{page}") | |
selected_project = gb.SelectedProject() | |
gb.ProjectUpdatePages( |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment