Hi,
I wrote a user defined bulk scattering dll (Non-sequential mode) that reads data from a txt file.
I create/edit the txt file with Python which I connect to ZEMAX via ZOS-API. What I need to do is as follows (all lines using ZOSAPI and python):
(1) Ray trace and Read detector data with Volume Physics bulk scattering set to None and save to a txt file (to be read by dll in step 3).
(2) Change some variables for various objects
(3) change bulk scattering to user defined dll
(4) Ray trace and Read detector data
(5) repeat from step 1
I’m having two issues (a small one and a huge one):
- the smaller issue - In step (1), how do I change Volume Physics bulk scattering to None? I tried the following:
Obj = TheNCE.GetObjectAt(1)
volphysdata = Obj.VolumePhysicsData
volphysdata.Model = ZOSAPI.Editors.NCE.VolumePhysicsModelType.None
However, Python doesn't allow this (as None is a protected variable). So, I found a different method which works , by changing to AngleScattering type and then set meanpath to zero (this acts exactly like the None option):volphysdata.Model = ZOSAPI.Editors.NCE.VolumePhysicsModelType.AngleScattering
volphysdata.ModelSettings._S_AngleScattering.MeanPath = 0
I can probably live with that but if anyone know how to change to None, that would be better.
- The larger issue. In step 3 when loading the dll again (doing it manually at the moment), and reading the data in step 4 I notice nothing changed, and detector data showed same numbers (output power)
so I read about this in the following example: https://support.zemax.com/hc/en-us/articles/1500005576142-How-to-read-a-static-data-file-into-a-user-defined-surface
and it seems that the dll is only loaded once when opticstudio is first opened. I tried it and indeed I see the changes after restarting Opticstudio.
Any ideas on how to reload the dll through Python and retrieve the new data in the txt file?
Thanks in advance!
Eyal