Skip to main content

Good afternoon! I am studying the ZPL macro language in order to simplify the analysis of data in the optimization process. In the macro being developed, I would like to implement the function of sorting optimization operands by their contribution. I know that such information is in the "" section, but I'm interested in the implementation in the ZPL language. There are no problems with the sort itself, I use the IF-THEN conditions in sequence, however, I cannot find a way to display the name of the operand by its ID code. Initially, I thought that the numerical function OPER(…,1) could give me the name of the operand in the string, however, as it turns out, this numeric function returns the ID code of the operand. Could you help me? Thanks

 

Hi Devorse,

 

If I understood correctly, you want a function that returns an operand name (as a string type) given its ID code. Functions that have a string return type in ZPL are listed in the Help File under the String Functions section (The Programming Tab > About the ZPL > String Functions). However, there is no such funciton in that section and it probably doesn’t exists for the moment. Strangely enough, this function exists for Tolerance Operands ($TOLOPERAND).

You could make a lookup table where you store the operand name and its corresponding code using the OCOD numeric function for example. Then, you could have a function that returns the name from that table based on a specific code.

Take care,

 

David

 


Hi David,
Sorry for my bad English, I use a translator to communicate. You correctly understood the task that I would like to implement. I did think about something like a complex IF-THEN condition that would replace the function I was looking for, but I was stopped by the number of operands that need to be included in this condition. Thanks for your input in resolving this issue.


Hi Devorse,

 

Don’t be sorry, English was not the problem. I always re-state the problem to make sure I understood it correctly.

If you tell us more about why you want to retrieve the operand name as a string, the community can give further recommandation also.

Take care,

 

David

 


Thank you for actively participating in the discussion, David
My global goal is to create a macro that would facilitate the iterative process of optimizing systems with variable characteristics. I've been wondering about two things for a long time:
1. For me, the editor window of the merit function is subjectively inconvenient, I would like to be able to create tabs, similar to how it is implemented in an Internet browser, and use each tab for a separate configuration. This presentation of information greatly simplifies the analysis of information in the merit function editor for systems with multiple configurations. However, this is an absolutely subjective desire, which cannot be realized at the level of working with macros.
2. It is much more realistic to create a macro that would process the data from the merit function editor. I have recently been interested in macros, but I have already managed to implement the output of information about the distribution of the sums of operad contributions belonging to individual configurations, regardless of the position of the operand in the editor or their total number. The second goal was to supplement the macro's text report with information about 5, 10, or any number of the most significant operands relative to their contributions. Well, the third stage was the inclusion of information about the distribution of contributions for individual operands of interest, mainly operands for optimizing aberrations.
I understand that all this information is available in the merit function editor, but it takes a significant amount of time and effort to analyze it with an increase in the number of operands, which increases the likelihood of an error.
Speaking of the question this forum page is dedicated to, I would most likely go down the path of using a third-party macro call in silent mode, the sole purpose of which would be to identify the operand to its id code. It's also possible to assign a string value to an array variable, then I could call a specific array value that would match the operand code and return the string value of the operand name. Although there are doubts about this.


Hi Devorse,

 

Thank you for the thorough description of your application. I particularly like the idea of ordering the Merit Function operands by their contributions.

You’ve rightly realized the limits of ZPL, and adjusted your requirements accordingly. However, I’d like to point you in the direction of the ZOS-API as well. I know you might be less familiar with it, and it does have a learning curve, but it also more powerful than ZPL. One thing you can do, for example, is browse the entire Merit Function, and list the name of the operands using the TypeName property. In Python, the code looks like so (without the connexion part):

 

TheMFE = TheSystem.MFE
OperandsNumber = TheMFE.NumberOfOperands

for OperandIndex in range(1, OperandsNumber+1):
    CurrentOperand = TheMFE.GetOperandAt(OperandIndex)
    print(CurrentOperand.TypeName)

 

And these would be the results:

There are some good starting articles on the Knowledgebase about the API. Have a look at it, and tell me what you think. I’m always happy to help if you need further help in that direction.

Take care,

 

David


Hi, David.

Sorry for taking so long to answer.
I've actually already thought about starting to learn ZOS-API. I think that as the tasks that I can't do with macros increase, my motivation and need to solve problems will force me to move to ZOS-API.
Thanks for your advice.


Reply