cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X

Creo automation: start Creo with trail-file by e.g. python command

ME89
2-Explorer

Creo automation: start Creo with trail-file by e.g. python command

I want to do some automated Tasks in Creo controlled by a python script.

 

I prefer a simple solution without the need of extra Software (creoson / creopyson).

 

What works is to start Creo with a Batch file or from cmd with the Trail-file. (parametric.exe .psf Trail.txt)

But when I start Creo like this from within python, the Trail file is ignored. I don't know why.

 

I use the external Analysis and .csv files to change Parameters and get measurements. The csv-files are read/written with the python script.

 

Is there something in Creo, which blocks the Trail-file when started from python?

I think it would be the same, if I use a different programming language.

 

I've tried the following:

 

batch-file:

"C:\Program Files\ptc\Creo 4.0\M070\Parametric\bin\parametric.exe" "C:\Program Files\ptc\Creo 4.0\M070\Parametric\bin\parametric1.psf" M:\test_trail.txt

 

python commands:

start with batch file:

import os
import subprocess

os.chdir(pathlib.Path(r"C:\Program Files\ptc\Creo 4.0\M070\Parametric\bin"))
test = subprocess.Popen(r"M:\start_creo_with_trail.bat")

 start directly:

import os
import subprocess

os.chdir(pathlib.Path(r"C:\Program Files\ptc\Creo 4.0\M070\Parametric\bin"))
test = subprocess.Popen(["parametric.exe","parametric1.psf","M:\test_trail.bat"])

 

ACCEPTED SOLUTION

Accepted Solutions

Additional note:

Maybe M:\test_trail.txt is causing problem, i.e. mapped drive M:. Try moving trail file to C: drive.


Martin Hanák

View solution in original post

4 REPLIES 4
MartinHanak
24-Ruby III
(To:ME89)

Hi,

below you can find information related to my testing...

---

Python 3.6

---

I asked Google ... python start batch script

... and used information available on https://datatofish.com/batch-file-from-python/ page.

---

I created simple trail file ... it contains two commands:

1.] Working Directory setting (myassembly.asm is located in it)

2.] File > Open > myassembly.asm

---

mh_parametric.bat

 

 off
"E:\PTC\Creo4_M120\Creo 4.0\M120\Parametric\bin\parametric.exe" "E:\PTC\Creo4_M120\Creo 4.0\M120\Parametric\bin\parametric.psf"  E:\users\Anaconda3_private\mh_trail.txt

 

---

mh_launch_creo.py

 

import subprocess
subprocess.call([r'E:\users\Anaconda3_private\mh_parametric.bat'])

 

---

I can run successfully following command from Command Prompt window

 

python.exe E:\users\Anaconda3_private\mh_launch_creo.py

 

---

 


Martin Hanák

Additional note:

Maybe M:\test_trail.txt is causing problem, i.e. mapped drive M:. Try moving trail file to C: drive.


Martin Hanák
ME89
2-Explorer
(To:MartinHanak)

Hi MartinHanak,

 

with your help I've found out why it didn't worked. Thanks!

 

For coding I use Visual Studio Code with python Extension together with miniconda.

One of it's Advantages is the inbuilt terminal. But here it's the root cause for the failure.

 

Using Anaconda Prompt the Code works as it should.

But I don't know in Detail, why VS Code runs this python command / cmd command different.

DavidBigelow
17-Peridot
(To:ME89)

Trail Files... 🙄

 

In CREOSON / CREOPYSON ... did the connection : start_creo not work?

 

Dave

 

 

 

Announcements


Top Tags