Skip to main content
1-Visitor
August 11, 2014
Question

Batch file that runs same trail file on multiple parts

  • August 11, 2014
  • 9 replies
  • 6711 views

Hi!

I registered here to ask this question. I've been working on it off and on for a week and can't quite figure out where I'm going wrong.

I'm going to have about 100 parts coming through that I need to populate parameters, recreate layers, and rename datums for (and a couple other tasks). So I recorded a trail file that will do the tasks. I tested it independently and it works no problem.

I then wrote a .BAT file that will go through the directory I give it (where the parts are located), it will export the list of parts to a text file.

Using this list, I set up a FOR loop to replace the part number in the trail file at each iteration.

The problem I'm running into is that when the batch file directs Creo to open a file, I get this message:

Cannot find C:\Users\%username%\Desktop\AutoCreo\Backup\PA.txa C:\Users\%username%\Desktop\AutoCreo\Backup\Test_Folder\%%a

Is Creo trying to open that as a single file, instead of opening %%a (Part from list) and running PA.txa (Trail File)?

I tried inserting pro_wait as well, as it was a separate command I ran across that may or may not help

Here is my code:

CODE:

@ECHO OFF

ECHO Brought to you by: ME

:: Prompts user for the directory

set /p pathName=Enter the File Path of the folder:

set /p username=Enter your username:

:: 1. Change to the location set above

:: 2. List all files in that directory and store in a text file desktop

cd %pathName%

dir /s /b *.* > c:\users\%username%\desktop\list.txt

:: 3. Opens Creo then runs 'for loop' to run script against each file in list.txt

:: This sets and populate parameters

:: 4. Add -g:no_graphics to run in non windows mode

for /f "delims=" %%a in (c:\users\%username%\desktop\list.txt) do ("c:\Program Files\PTC\Creo 2.0\Parametric\bin\parametric.bat" pro_wait "C:\Users\%username%\Desktop\PA.txa %%a")

Pause

In summary, the .bat file works up to a point. It stops when Creo is open/running and the OPEN FILE window is there asking for which part to open. The .bat file inputs (what looks to me to be the correct filepath) and then gives me that error.

I read something about a protk.dat file? Is this necesarry to get the .bat to communicate directly with Pro/E ?

I would really appreciate any help I can get. I've tried asking a few other places as well and haven't had much luck.

Thank you for your time!


This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.

9 replies

1-Visitor
August 12, 2014

Try sending the output of the 'for' substitution to a file and see if it looks right.

I've been looking at the manual pages for 'for,' but haven't gotten far enough to see if your syntax is what you need.

Off topic: Awk, grep, VBA, C, AutoIT, FORTRAN, Postscript; these I get, but not windows command scripting. I think the goofy things like use % if you type it, but %% if it's in a batch file - for the same result - is what makes it hurt to read.

1-Visitor
August 12, 2014

The problem, it seems to me, is that running Creo only takes input from the txa file. I think Pro/E & Creo do not read any information from the CMD.

I think you have to embed the name of the file in the .txa file.

24-Ruby III
August 12, 2014

I agree with David, you have to put specific part name into a trail file, before you ask Creo to replay the trail file. Also I suggest to use lowercase name for the trail file.

Martin Hanak

1-Visitor
August 13, 2014

After reading your replies, I was thinking I would do this:

Set up a loop to have the batch file generate a new trail file for each iteration, that way the part number is embedded in the trail file as suggested. Then its just a matter of deleting/overwriting the previous trail file each time until it finishes the list.

I appreciate the help so far, and if anyone else has a suggestion, I'm all ears.

12-Amethyst
September 1, 2014

Take a look on this post:

Load multiple drawings into session at once

Jose