Continue to Site

Welcome to MCAD Central

Join our MCAD Central community forums, the largest resource for MCAD (Mechanical Computer-Aided Design) professionals, including files, forums, jobs, articles, calendar, and more.

Finding all files and one parameter

shuga_raye

New member
Right now I am in the calm before the storm! Slight lull in work butI know I will be swamped shortly. So I am trying to get all my ducks in a row. So this question popped into my mind. First of all, I have no file management software. Okay, the question, is it possible to get a list of all the files in a directoryand the value for a certain parameter for each file?
 
You can do this with a batch and trail file.


Create a trail file that:-
Opens Proe.
Change working directory to your parts directory.
Open a part.
Export the param.inf file.
Then exit proe.


Create folder proetrail.


Rename the trail file to trail.txt and move to folder proetrail.
You now have to split the trail file into 2 files:- trail1.txt and trail2.txt


trail1.txt contains all lines up to and including the line
1 `partname.prt`
Delete `partname.prt` but leave the 1. (The cursor should be on the same line)
Save the file.


trail2.txt contains all lines below
1 `partname.prt`
Save the file.


Create runtrail.bat in folder proetrail.
Copy and paste from below and change the top 3 set lines to suit your system.


The batch file creates a trailfile for each part by combining trail1.txt, partname and trail2.txt.
proe2001.bat then uses the created trailfile to open each part and export the param.inf.
runtrail.bat then extracts the parameter value.


From windows explorer just doubleclick to run the batchfile runtrail.bat


partlist.txt is created in folder proetrail.


Note: This method works but is slow.


This is runtrail.bat
************************************************************ ******************
@echo off
::Create partlist with parameter from parts


::change to your proe start file
set startproe=C:\PTC\2001\bin\proe2001.bat


::change to your part directory
set partdir=C:\your_part_directory


::change to your parameter name (must use " ")
set paramname="name"


set startdir=%CD%
set paramfile=%partdir%\param.inf
echo. > %startdir%\partlist.txt


set CONTINUE_FROM_OOS=true
for %%i in (%partdir%\*.prt*) do (
echo. `%%~ni.prt`>%%~ni.txt
copy trail1.txt+%%~ni.txt+trail2.txt %%~ni.tmp >nul
del %%~ni.txt
)
echo Running ProE
for %%i in (*.tmp*) do call :process %%i
if exist %partdir%\std.out del %partdir%\std.out


exit


:process
set partname=%1
set trailname=%partname:.tmp=.txt%
move /y %partname% %partdir%\%trailname%
echo. Processing %partname%
cd %partdir%
call %startproe% %trailname% -g:no_graphics pro_wait
del %trailname%
for /F "eol=- tokens=3*" %%j in ('find /i %paramname% %paramfile%') do set paramvalue=%%j %%k
set paramvalue=%paramvalue:"=%
del %paramfile%
cd %startdir%
echo %partname:.tmp=% %paramvalue% >> %startdir%\partlist.txt
************************************************************ ******************
 
D&mn!! Sweet!
smiley36.gif
 
The batchfile above only works for filenames of name.prt


If you have the extra number suffix e.g name.part.1 you will have to change the following lines,


echo. `%%~ni.prt`>%%~ni.txt TOecho. `%%~ni`>%%~ni.txt


set trailname=%partname:.tmp=.txt%TO set trailname=%partname:.prt.tmp=.txt%


Hope this helps.
 

Sponsor

Articles From 3DCAD World

Back
Top