Skip to main content

How to modify tolerance script in macro

  • December 29, 2021
  • 4 replies
  • 774 views

I want to use macro do automatic tolerance analysis, could i modify the tolerance script code in macro code. how to do it if could. thanks!

Did this topic help you find an answer to your question?

4 replies

Alissa Wilczynski
Zemax Staff
Forum|alt.badge.img+3

Do you mean that you want your macro to open and edit your tolerance script? Or you want a macro to run a tolerance analysis using a pre-defined tolerance script?


  • Author
  • Monochrome
  • 1 reply
  • January 13, 2022
Alissa Wilczynski wrote:

Do you mean that you want your macro to open and edit your tolerance script? Or you want a macro to run a tolerance analysis using a pre-defined tolerance script?

I want to use macro open and edit tolerance script.


David.Nguyen
Luminary
Forum|alt.badge.img+2
  • Luminary
  • 1098 replies
  • January 13, 2022

Hi Lei,

 

I don’t think this is possible, but the tolerance scripts are just text-files. You can open them with any programing langages, and make modifications to it. Then, you could save the different tolerance scripts you want and have a macro run through those. Alternatively, is the ZOS-API a possibility for you or you don’t want to get into this at all?

If you tell us what you want to do in more details, it is easier to come up with an example for you.

Take care,

 

David


Allie
Zemax Staff
Forum|alt.badge.img+2
  • Zemax Staff
  • 338 replies
  • January 13, 2022

Hi @lei.song ,

To add on to what David said - since tolerance scripts are just text files, you do have the option of reading them into the ZPL with the file I/O commands we provide. For example, READSTRING will read a full line from a text file into the ZPL. Additionally, the command OUTPUT will allow you to choose where to write your PRINT commands - either to the screen, or to some external file. Finally, you can use string functions like $LEFTSTRING(A$, n) to modify a line. 

All of these commands can be used to modify or create a new tolerance script through the ZPL as David mentioned. 

What do you want to edit within the tolerance script? Maybe there’s an easier way to achieve what you’re looking for.


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings