Jump to content

I've always wanted to use Autorun more [looking forward from you to improve]


---
 Share

Recommended Posts

because it comes with no additional cost, wuhu.

But it only seemed like it's going to work for me if the part has the same geometry and size.
And I have silghtly different size on each part and the same geometry.

So let's solve this with reading .para on start, but when each part is measured, just rewrite the variable values, so it fits the next part.

408_114051fc00bfc7520ef2df6c06c0947a.jpg

408_1fd39454dc748708591ba6db63e90633.jpg




Presettings:

// dont know how to multi line comment
// wait for seconds
wait(1)
// read from .para file
parafile = getActualInspectionDir() + "\external\" + "input" + ".para"
readPCMFile(parafile)
Postsettings:

// run python with powershell, needs cleanup
pws = getActualInspectionDir() + "\external\" + "run_python" + ".ps1"
comcal = "powershell.exe -File " + qm() + pws + qm()
systemCall(comcal)
wait(5)



Powershell script is then calling python.exe:

408_c6deab5f07e511db744e4f681a7d422c.jpg




run_python.ps1:

$filepathvar = $PSScriptRoot
. "$filepathvar\python\python.exe" "$filepathvar\python_script\variable.py" "$filepathvar\input.para"




python.exe compiles and runs code/script variable.py:

408_dca61341018d7533fb21c53523a55845.jpg

#   2023 Original code GPT-3.5
#   2023 Modified by Rok Medic <dm70dm@gmail.com>

import sys

# Specify the file path
file_path = sys.argv[-1]

# Read the contents of the file
with open(file_path, 'r', encoding='utf-8') as file:
  lines = file.readlines()

# Extract the variables and values from the lines
numVars = int(lines[0].split('=')[1])
variables = []
values = []

lines.pop(0)

for line in lines:
  parts = line.split('=')
  variable = parts[0].strip()
  value = parts[1].strip()
  variables.append(variable)
  values.append(value)

# Modify the lines with updated variables and values
new_lines = [
  f"{variable} = {value}\n" for variable, value in zip(variables, values[numVars:])
]
new_lines.insert(0, "numVars = "+str(numVars)+"\n")

# Write the updated lines back to the file
with open(file_path, 'w', encoding='utf-8') as file:
  file.writelines(new_lines)
  




We take var1 into diameter:

408_497d0e5d06610e59178b1cc91e14a987.png





and var1 and var101 to throw out correctly named reports and .zmp files:

408_892b79b1874c372ba8b0af6a308474a1.jpg




In the python folder is extracted from the link ->
EDIT: embeddable version not installer https://www.python.org/ftp/python/3.12. ... -amd64.zip


Inside input.para, numVars = 2 will replace 2 lines each run:

408_0a5a8d4dc82c897044c7132da799a81e.png

numVars = 2
var1 = 24.999
var101 = 1111
var2 = 72.954
var102 = 2222
var3 = 62.955
var103 = 3333
var4 = 12.956
var104 = 4444

Link to comment
Share on other sites

EDIT python download link: embeddable version not installer
so no need for windows admin to install
Link to comment
Share on other sites

 Share

×
×
  • Create New...