Jump to content
Private Messaging is activated - check "How to" on how to disable it ×

error in sending arguments in 2025 Software


---
 Share

Recommended Posts

---

Hello everyone,

I'm trying to follow the instructions presented in 2025/howtos/starting_options/starting_options.html.

I encountered an error when sending arguments from an exe file to the python script inside ZEISS software.

params = {'portno': main.port, 'insp_id': insp_id, 'partno': partno, 'serlno': srlno}

result = subprocess.run(["C:/Program Files/Zeiss/INSPECT/2025/bin/ZEISS_INSPECT.exe", "-eval", "gom.script.userscript.service_coordinator(parameters=" + str(params) + ")"], text=True, capture_output=True, check=True)

In service coordinator.py,  I got an error which says insp_id is not defined. Could you please help me to solve the issue?

if 'insp_id' not in globals() or 'portno' not in globals() or  'serlno' not in globals():
    insp_id = 'default_value_1'
    portno = 'default_value_2'
    serlno='default_value_3'
if hasattr(gom, 'read_parameters'):
    gom.read_parameters(globals())
insp_id=insp_id
serlno=serlno
portno=portno
variable_list=[portno,insp_id,serlno]
print(variable_list)

Link to comment
Share on other sites

---

Hi cansetm,

I tried to reproduce your approach as follows.

  1. I created the following Python script which is executed from the command line:
    import subprocess
    
    params = {'portno': 1, 'insp_id': 'insp123', 'partno': 'part1', 'serlno': '1234'}
    
    result = subprocess.run(["C:/Program Files/Zeiss/INSPECT/2025/bin/ZEISS_INSPECT.exe", "-eval", "gom.script.userscript.service_coordinator(parameters=" + str(params) + ")"], text=True, capture_output=True, check=True)
    As compared to your script, I just replaced the values in the 'params' dictionary.
  2. I created an App with the following implementation of 'service_coordinator.py':
    if 'insp_id' not in globals() or 'portno' not in globals() or 'serlno' not in globals():
    	insp_id = 'default_value_1'
    	portno = 'default_value_2'
    	serlno = 'default_value_3'
    	
    if hasattr(gom, 'read_parameters'):
    	gom.read_parameters(globals())
    
    variable_list=[portno,insp_id,serlno]
    print(f"{variable_list}")
    with open("C:/Temp/app.log", 'w') as f:
    	f.write(f"{variable_list}")

    As compared to your script, I removed the variable assignments at the end and added writing of the variables to the file "app.log".
    When I check the contents of "app.log", I see

    [1, 'insp123', '1234']

Hope this helps!

Best regards,

Matthias

Link to comment
Share on other sites

---

Hello Matthias,

I tried with your method. It worked only first time when I run the code, and variables have the default values  in all other attempts.

What could be the reason of the problem? Is there any other robust way of sending arguments?

Many Thanks,

Canset

Link to comment
Share on other sites

---

Hi Canset,

What exactly do you mean by "It worked only first time when I run the code"? Does this mean you leave ZEISS INSPECT open and run the Python script from the command line a second time?

Best regards,

Matthias

Link to comment
Share on other sites

---
Posted (edited)

Hello Matthias,

It only worked  one time and after that I closed the ZEISS Inspect and command prompt, and tried to reproduce the case from the command line.  Log files were remained empty for the all other attempts.

You can also find the service log which shows that values of the variables could not be assigned.

Many thanks,

Canset

Screenshot 2025-04-09 105734.jpg

Edited
Link to comment
Share on other sites

---

Hello Canset,

When reading your previous posts, I did not realize that you were actually sending the arguments to a script working as a service! I will have to check if this actually works. The mechanism I described is intended for "normal" scripts.

Best regards,

Matthias

 

Link to comment
Share on other sites

---

Hello Matthias,

Actually, I am sending arguments to a script which has a call for service function inside but this script is not the service.py itself.

Many thanks for your effort 🙂

Canset

Link to comment
Share on other sites

---

Hello Canset,

Thanks for the clarification. Now I have no idea what might go wrong on your side. Yesterday I tried the setup I posted on Tuesday multiple times and did not encounter any issues.

Best regards,

Matthias

 

Link to comment
Share on other sites

Hello Matthias,

Thanks for your help. I solved the problem with asyncio. 

I have one more question. Is  it possible to use services for let's say for importing mesh data,report editing purposes?

Because when I use the service for this kind of task, service is running without encountering any problem but ZEISS  could not continue to task  when user is logged out. It makes me think that these services are different compared to windows service format.

Any idea why this happens?

Thanks,

Canset

Link to comment
Share on other sites

 Share

×
×
  • Create New...