Solved

Automatically Update NSC Object Properties after being created by a ZPL macro?

  • 26 April 2021
  • 3 replies
  • 166 views

Hi Zemax Community,


I wrote a macro to create a number of objects in Non-Sequential Mode and pass various details to be sent to a specified .dll, including the Split option, DLL, Orders, and all the other details required for the .dll. When I run the macro, the objects are created as expected with all typical details showing up in the NSC editor (e.g. positions, tilts, size, thickness, material, etc.). However, in the diffraction tab, only the correct Split, DLL, and Orders show up (correctly) while the edit boxes for the details for the .DLL are not present:



If I then change the DLL and then set it back to the original, desired DLL, the edit boxes appear with the values I passed to the object originally:



Is there a way to have this show up properly without manually changing the DLL to a different DLL, then back again for each object? The main reason I wrote the macro was to auto-create many objects instead of manually entering values into each element.


Additionally, if I copy an object and then paste it, the Properties window returns to hiding the edit fields. Is there a setting I have incorrectly set that is doing this?


Thanks in advance.

icon

Best answer by Allie 28 April 2021, 19:16

View original

3 replies

Userlevel 7
Badge +3

Hey Roger,


I think once you specify the dll, you need to issue an UPDATE to actually load it. Other than that, I'd need to see the code to comment further.


- Mark

Userlevel 6
Badge +2

Hi Roger and Mark,


I have actually confirmed this behavior. It appears to be a graphics glitch that occurs when we try to programmatically change from a setting which has no extra parameters to a setting which has at least one. 


So far, I have found that we can get around this by saving and re-loading the file after updating the DLL. This can be done with SAVELENS and LOADLENS as is shown below:


 


INSERTOBJECT 1, 1

SETNSCPROPERTY 1, 1, 0, 1, 'NSC_RBLK'

SETNSCPROPERTY 1, 1, 91, 1, 2

SETNSCPROPERTY 1, 1, 92, 1, 'diff_all_transmit.DLL'

UPDATE ALL

lensFile$ = 'C:\Users\...\test.zmx'

SAVELENS lensFile$

LOADLENS lensFile$

SETNSCPROPERTY 1, 1, 95, 1, 5

SETNSCPROPERTY 1, 1, 96, 1, 5

 


Let me know how this works for you, Roger!


Best,


Allie

Hi Mark and Allie,

Thanks for your replies. Similarly to Allie, I included the command 'UPDATE ALL' at the end of the macro.


Luckily, it seems to just be a graphics issue and the values are correctly passed from the macro to the system. Using the SAVELENS and LOADLENS functions works to get around this glitch.


Roger

Reply