Skip to main content

Hello Everyone,

I am trying to change the Aperture file of a surface aperture using python. All I could do is to change the Aperture type to User Aperture but the Aperture file is not specifyed.

This is the code I am using

filename= ‘HP.uda’
User_Aper =TheLDE.GetSurfaceAt(2).ApertureData.CreateApertureTypeSettings(ZOSAPI.Editors.LDE.SurfaceApertureTypes.UserAperture)
User_Aper.ApertureFile = filename
Surface_3.ApertureData.ChangeApertureTypeSettings(User_Aper)
 
Using Matlab, it is working perfectly using the same code and also, it works that I can change the Aperture file manually in zemax so this means the aperture uda file is at the correct location with the correct content.

I also tried to change the filename string to the full directory of the uda file and it is not working too.

 

tMod note: moved to more appropriate forum for ZOS-API related discussions.] 

 

Hi Baraka,

 

I had to modify your code a little bit because Surface_3 isn’t defined, but other than that it works fine for me on Python 3.8.13 and Pythonnet 2.52. Could you check and tell us your version of Python and Pythonnet? There have been issues with more recent versions of Pythonnet lately.

The code I used with a default lens file is the following:

filename = 'letterC.uda'
Surface_1 = TheSystem.LDE.GetSurfaceAt(1)
User_Aper = Surface_1.ApertureData.CreateApertureTypeSettings(ZOSAPI.Editors.LDE.SurfaceApertureTypes.UserAperture)
User_Aper.ApertureFile = filename
Surface_1.ApertureData.ChangeApertureTypeSettings(User_Aper)

Hope this helps and take care,


David


Hello David,

Thank you so much for your help. It was really useful.

I had pythonnet 3.0 installed yes. So, I uninstalled it and then intalled pythonnet 2.5.2 and it is working perfectly.

Sincerely,

Baraka


Reply