Skip to content

Issue using pyZOS with OpticStudio 20.1 #11

@Jonas231

Description

@Jonas231

Hello,

quite some work!

Here is my issue:
I ran this code:

import os
import sys
import numpy as np
from IPython.display import display, Image, YouTubeVideo
import matplotlib.pyplot as plt

Imports for using ZOS API in Python directly with pywin32

(not required if using PyZOS)

from win32com.client.gencache import EnsureDispatch, EnsureModule
from win32com.client import CastTo, constants

Import for using ZOS API in Python using PyZOS

import pyzos.zos as zos

Set this variable to True or False to use ZOS API with

the PyZOS library or without it respectively.

USE_PYZOS = 1

if USE_PYZOS:
osys = zos.OpticalSystem(sync_ui=False) # Directly get the Primary Optical system , # sync_ui=False
else:
# using ZOS API directly with pywin32
#EnsureModule('ZOSAPI_Interfaces', 0, 1, 0)

#EnsureModule('{EA433010-2BAC-43C4-857C-7AEAC4A8CCE0}', 0, 1, 0)     # geändert --> funktioniert
#EnsureModule('{F66684D7-AAFE-4A62-9156-FF7A7853F764}', 0, 1, 0)
    
connect = EnsureDispatch('ZOSAPI.ZOSAPI_Connection')
app = connect.CreateNewApplication() # The Application
osys = app.PrimarySystem             # Optical system (primary)

common

osys.New(False)

Set aperture Aperture

sdata = osys.pSystemData
sdata.pAperture.pApertureValue = 40

# Set fields

field = sdata.pFields.AddField(0, 5.0, 1.0)

# Set wavelength

sdata.pWavelengths.SelectWavelengthPreset(zos.Const.WavelengthPreset_d_0p587);

# Create surfaces

osys.zInsertNewSurfaceAt(1)

And I get the following error:

File "C:\Users\herbst.spyder-py3\pyZEMAX\pyZOS_test.py", line 45, in
osys = zos.OpticalSystem(sync_ui=False) # Directly get the Primary Optical system , # sync_ui=False

File "C:\Users\herbst\AppData\Local\Continuum\anaconda2\envs\mypython3\lib\site-packages\pyzos\zos.py", line 296, in init
_replicate_methods(self._iopticalsystem, self) #*commented

File "C:\Users\herbst\AppData\Local\Continuum\anaconda2\envs\mypython3\lib\site-packages\pyzos\zosutils.py", line 64, in replicate_methods
setattr(dstObj, key, zos_wrapper_deco(value))

File "C:\Users\herbst\AppData\Local\Continuum\anaconda2\envs\mypython3\lib\site-packages\pyzos\zosutils.py", line 57, in zos_wrapper_deco
varnames = func.im_func.func_code.co_varnames # alternative is to use inspect.getargspec

AttributeError: 'function' object has no attribute 'im_func'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions