-
Notifications
You must be signed in to change notification settings - Fork 64
/
blankFile.py
42 lines (34 loc) · 1.29 KB
/
blankFile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#-------------------------------------------------------------------------------
# Name: module_name.py
# Purpose: A blank file. Use this skeleton file as model for scripts
# that explicitly adds PyZDDE path to the Python search path.
#
# Created:
# Copyright:
# Licence: <your licence>
#
# Note: The coding style shown below is "safe" (using exception handling).
# In 95% of cases you don't need to use exception handling. PyZDDE
# is pretty stable.
#-------------------------------------------------------------------------------
from __future__ import print_function
import sys
import traceback
#****************** Add PyZDDE to Python search path **************************
PyZDDEPath = 'C:\PyZDDE' # Assuming PyZDDE unzipped here; if not, change the path
# appropriately
if PyZDDEPath not in sys.path:
sys.path.append(PyZDDEPath)
#******************************************************************************
import pyzdde.zdde as pyz
# Create a DDE link object
ln = pyz.createLink()
try:
# Write your code to interact with Zemax, for example
zemaxVer = ln.zGetVersion()
print("Zemax version: ", zemaxVer)
except Exception, err:
traceback.print_exc()
finally:
#Close DDE link
ln.zDDEClose()