Zuken.e3
1# More reliable way of making a COM connection to Zuken 2# Taken from "https://stackoverflow.com/a/69288053" by Pelelter 3def dispatch(app_name: str): 4 try: 5 from win32com import client 6 app = client.gencache.EnsureDispatch(app_name) 7 except AttributeError: 8 # Corner case dependencies. 9 import os 10 import re 11 import sys 12 import shutil 13 # Remove cache and try again. 14 MODULE_LIST = [m.__name__ for m in sys.modules.values()] 15 for module in MODULE_LIST: 16 if re.match(r'win32com\.gen_py\..+', module): 17 del sys.modules[module] 18 shutil.rmtree(os.path.join(os.environ.get('LOCALAPPDATA'), 'Temp', 'gen_py')) 19 from win32com import client 20 app = client.gencache.EnsureDispatch(app_name) 21 return app 22 23def print(msg, popup=0, item=0): 24 """ 25 Shorthand for the "PutInfo" method 26 27 Args: 28 msg: Message to display (gets converted to string automatically, so anything works) 29 popup: Whether to display an additional dialogue or not 30 item: ID of an item in the project (allows you to jump to it) 31 """ 32 E3.PutInfo(popup, msg, item) 33 34def warn(msg, popup=0, item=0): 35 """ 36 Shorthand for the "PutWarning" method 37 38 Args: 39 msg: Message to display (gets converted to string automatically, so anything works) 40 popup: Whether to display an additional dialogue or not 41 item: ID of an item in the project (allows you to jump to it) 42 """ 43 E3.PutWarning(popup, msg, item) 44 45def error(msg, popup=0, item=0): 46 """ 47 Shorthand for the "PutError" method 48 49 Args: 50 msg: Message to display (gets converted to string automatically, so anything works) 51 popup: Whether to display an additional dialogue or not 52 item: ID of an item in the project (allows you to jump to it) 53 """ 54 E3.PutError(popup, msg, item) 55 56def message(msg, item=0): 57 """ 58 Shorthand for the "PutMessage" method 59 60 Args: 61 msg: Message to display (gets converted to string automatically, so anything works) 62 item: ID of an item in the project (allows you to jump to it) 63 """ 64 E3.PutMessage(msg, item) 65 66def verify(msg, popup=0, item=0): 67 """ 68 Shorthand for the "PutVerify" method 69 70 Args: 71 msg: Message to display (gets converted to string automatically, so anything works) 72 popup: Whether to display an additional dialogue or not 73 item: ID of an item in the project (allows you to jump to it) 74 """ 75 E3.PutVerify(popup, msg, item) 76 77E3 = dispatch("CT.Application") 78"""E3 Object - Links to all instances of the application""" 79 80Job = E3.CreateJobObject() 81"""E3 Job Object - Links to a single instance of the application"""
def
dispatch(app_name: str):
4def dispatch(app_name: str): 5 try: 6 from win32com import client 7 app = client.gencache.EnsureDispatch(app_name) 8 except AttributeError: 9 # Corner case dependencies. 10 import os 11 import re 12 import sys 13 import shutil 14 # Remove cache and try again. 15 MODULE_LIST = [m.__name__ for m in sys.modules.values()] 16 for module in MODULE_LIST: 17 if re.match(r'win32com\.gen_py\..+', module): 18 del sys.modules[module] 19 shutil.rmtree(os.path.join(os.environ.get('LOCALAPPDATA'), 'Temp', 'gen_py')) 20 from win32com import client 21 app = client.gencache.EnsureDispatch(app_name) 22 return app
def
print(msg, popup=0, item=0):
24def print(msg, popup=0, item=0): 25 """ 26 Shorthand for the "PutInfo" method 27 28 Args: 29 msg: Message to display (gets converted to string automatically, so anything works) 30 popup: Whether to display an additional dialogue or not 31 item: ID of an item in the project (allows you to jump to it) 32 """ 33 E3.PutInfo(popup, msg, item)
Shorthand for the "PutInfo" method
Arguments:
- msg: Message to display (gets converted to string automatically, so anything works)
- popup: Whether to display an additional dialogue or not
- item: ID of an item in the project (allows you to jump to it)
def
warn(msg, popup=0, item=0):
35def warn(msg, popup=0, item=0): 36 """ 37 Shorthand for the "PutWarning" method 38 39 Args: 40 msg: Message to display (gets converted to string automatically, so anything works) 41 popup: Whether to display an additional dialogue or not 42 item: ID of an item in the project (allows you to jump to it) 43 """ 44 E3.PutWarning(popup, msg, item)
Shorthand for the "PutWarning" method
Arguments:
- msg: Message to display (gets converted to string automatically, so anything works)
- popup: Whether to display an additional dialogue or not
- item: ID of an item in the project (allows you to jump to it)
def
error(msg, popup=0, item=0):
46def error(msg, popup=0, item=0): 47 """ 48 Shorthand for the "PutError" method 49 50 Args: 51 msg: Message to display (gets converted to string automatically, so anything works) 52 popup: Whether to display an additional dialogue or not 53 item: ID of an item in the project (allows you to jump to it) 54 """ 55 E3.PutError(popup, msg, item)
Shorthand for the "PutError" method
Arguments:
- msg: Message to display (gets converted to string automatically, so anything works)
- popup: Whether to display an additional dialogue or not
- item: ID of an item in the project (allows you to jump to it)
def
message(msg, item=0):
57def message(msg, item=0): 58 """ 59 Shorthand for the "PutMessage" method 60 61 Args: 62 msg: Message to display (gets converted to string automatically, so anything works) 63 item: ID of an item in the project (allows you to jump to it) 64 """ 65 E3.PutMessage(msg, item)
Shorthand for the "PutMessage" method
Arguments:
- msg: Message to display (gets converted to string automatically, so anything works)
- item: ID of an item in the project (allows you to jump to it)
def
verify(msg, popup=0, item=0):
67def verify(msg, popup=0, item=0): 68 """ 69 Shorthand for the "PutVerify" method 70 71 Args: 72 msg: Message to display (gets converted to string automatically, so anything works) 73 popup: Whether to display an additional dialogue or not 74 item: ID of an item in the project (allows you to jump to it) 75 """ 76 E3.PutVerify(popup, msg, item)
Shorthand for the "PutVerify" method
Arguments:
- msg: Message to display (gets converted to string automatically, so anything works)
- popup: Whether to display an additional dialogue or not
- item: ID of an item in the project (allows you to jump to it)
E3 =
<win32com.gen_py.E3.series 2022.2301 Type Library.IApplicationInterface instance>
E3 Object - Links to all instances of the application
Job =
<win32com.gen_py.E3.series 2022.2301 Type Library.IJobInterface instance>
E3 Job Object - Links to a single instance of the application