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.

Startup Batch file

SEBNN

New member
I found a way to setup a batch file for startup about a year ago and haven't been able to find it since. It involved calling up ProE in the working directory of a part or assembly, locating a search.pro file to find all of the components, and worked every time. Does anyone know where I can find that tip, or have the information off hand? I am having trouble since I installed a new copy of ProE in getting this to work.


Thanks,


SEBNN
 
Here's the one that I use. It copies the latest confog.sup file from a network drive to the {loadpoint}\text directory, changes the working directory to the default working directory (with the config.pro file - with search.pro path), & opens the part chosen.





@echo off
copy /Y "n:\wildfire\config.sup" "C:\Program Files\proeWildfire 3.0\text\config.sup"
c:
cd \Wildfire
"C:\Program Files\proeWildfire 3.0\bin\proe.exe" %*
 
That is kind of close. The one I had allowed me to open an assembly from windows explorer or ProE and would then load all files and the config files using search.pro files. It was very functional and made loading large assemblies a snap versus the pain that I usually have. I would put the search paths into the config file, but I would prefer to have only one config file and then multiple search.pro files stored into each assemblies folder.
 
How about adding some lines like this to your batch file:
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">


echo.c:\path_to_whatever_1 >search.pro


echo.c:\path_to_whatever_2 >>search.pro


dir /ad /s /b >>search.pro</BLOCKQUOTE>


Whenever the batch file is run the first line will delete the old search.pro and add the first path to a new one. The second line can be repeated as much as required. The third line will add the current and all sub folders to the search.pro file.


Please note that the third line will only add correct paths if there is no spaces in any of the folder names. If you have spaces ProE will ignore the format this command provides. To make it work the batch file get much more complicated.


Ignoring the paths with spaces in the name is handy though. Our uses will create folders with spaces and copy files into them knowing that the search path will not find these files.


Kevin
 
kbrault said:
How about adding some lines like this to your batch file:
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">


echo.c:\path_to_whatever_1 >search.pro


echo.c:\path_to_whatever_2 >>search.pro


dir /ad /s /b >>search.pro</BLOCKQUOTE>


Whenever the batch file is run the first line will delete the old search.pro and add the first path to a new one. The second line can be repeated as much as required. The third line will add the current and all sub folders to the search.pro file.


Please note that the third line will only add correct paths if there is no spaces in any of the folder names. If you have spaces ProE will ignore the format this command provides. To make it work the batch file get much more complicated.


Ignoring the paths with spaces in the name is handy though. Our uses will create folders with spaces and copy files into them knowing that the search path will not find these files.


Kevin





This is different than what I had in mind, but I will give it a try as it may be a better way to do what I am trying to do. Just so I understand this correctly, this will do the following:


1) Delete the old search.pro file that I have (assuming I store the search.pro in the same folder as my config file (not in the folder where the assembly is).


2) Copy the path of the assembly/part I am opening to a new search.pro file


3) Copy the path of the folder containing the assembly/part to search.pro and all of the sub-folders that do not contain a " " in their name.


I am guessing that I can then referance only the one search.pro file in my config.pro file and have my startup batch run this first, and then run proe.exe.


So, as an example, if I direct the "ProE" icon on my desktop to "c:\ptc\bin\this file.bat" and then have the following in the "thisfile.bat"


echo.c:\ProE_Projects\P2112 >search.pro !This is the path to the old project main folder


echo.c:\ProE_Projects\P1278 >>search.pro !This is the path to the new project main folder of the assembly I double clicked on.


dir /ad /s /b >>search.pro


@echo off


cd C:\PTC\Text !Location of the Config.pro and Search.pro files


"C:\PTC\bin\proe.exe" %* !Runs ProE





The last three lines are what I have in there now, as I understand it to direct ProE to the config file and then to run it. The config file has a search_path_file ".\Search.pro"setting in itto direct it to the search.pro file that is in the same main folder as the main assembly. I do not have search.pro for subassemblies as the part files are in the same folder as the assembly files. So far I have only had a project that had a main assembly of subassemblies. I haven't had to go any farther than that.


I hope what I am trying to do makes sense as I am trying to setup ProE to work as seemlesly as possible like I had in the past. Also, the bat file I had used previously was for WF2, I do not know if this will make a difference.


Thanks,


SEBNN
 
Let me make sure I understand what you are doing.<?:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" />
You have changed the file association in Windows so when you double click on the
 
kbrault said:
Let me make sure I understand what you are doing.<?:namespace prefix = o ns = "urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><O:p></O:p>
You have changed the file association in Windows so when you double click on the
 
OK then ....


Add "search_path <xxx>" to your resident "config.pro" file as required for fixed paths.
Add "search_path_file .\search.pro" to your resident "config.pro" file.


Add:


echo.c:\path_to_whatever_1 >search.pro
echo.c:\path_to_whatever_2 >>search.pro
dir /ad /s /b >>search.pro


To your batch file.


If all your search paths are either fixed (in the config.pro or the "echo.c:\path_to_whatever_1 >search.pro") or are IN or UNDER the folder you are starting ProE from then it will work.


I envision your folder structure mimics your BOM structure. If so then this will work wonderfully unless you have child relationsips to higher level assemblies.


Kevin
Edited by: kbrault
 
kbrault said:
OK then ....


Add "search_path <xxx>" to your resident "config.pro" file as required for fixed paths.
Add "search_path_file .\search.pro" to your resident "config.pro" file.


Add:


echo.c:\path_to_whatever_1 >search.pro
echo.c:\path_to_whatever_2 >>search.pro
dir /ad /s /b >>search.pro


To your batch file.


If all your search paths are either fixed (in the config.pro or the "echo.c:\path_to_whatever_1 >search.pro") or are IN or UNDER the folder you are starting ProE from then it will work.


I envision your folder structure mimics your BOM structure. If so then this will work wonderfully unless you have child relationsips to higher level assemblies.


Kevin


Kevin,


I think I have a good idea of what is going on. Also, yes, my folder structure reflects my BOM structure. All children are in subfolders of their parent assembly or the main assembly.


The one question I still have is about the following:


echo.c:\path_to_whatever_1 >search.pro
echo.c:\path_to_whatever_2 >>search.pro



The name "path_to_whatever_1 & 2", do I need to add these in each time? The Search.pro file will be in the main assembly folder which is where I will open ProE from by double-clicking on the assembly.asm file. Is there a way to make the "path_to_whatever" a variable that is automatically called from the batch file? Otherwise will Ineed to create a new pathin the batch file for each search.pro file? Sorry to ask this one again, I am fairly new to using batch files and am not certain how this would be able to create a newsearch.profile unless I have multiple search.pro files or put in a new pathfor the new search.pro file manually.


Thanks,


SEBNN
 
1st: One ">" will direct the output to "new" file. If that files exits it will be deleted and recreated. Two ">>" appends the output to the next line of a file (new or not).


You do not need "echo.c:\path_to_whatever_X >>search.pro" in the batch file if you have the path in your resident "config.pro". And vise versa.


However, if you use "dir /ad /s /b >>search.pro" you willNOT want to append this output to an existing"search.pro". Your "search.pro" file will continually grow everytime you start ProE. You will want to create a new "search.pro" in the workingfolder evertime ProE is started (e.g. by using ">", BTW, "dir /ad /s /b >search.pro", note one ">", does not work in all situationssince itmay only write the last folder found).


I am not sure what the advantage would be to have the paths as variables.


I would recommend you "hard code"(one time deal) your paths into your batch file and write them to a new "search.pro" everytime ProE is started. That way if your users modify the paths in the resident "config.pro" file the paths willstill be correct.


Kevin


ps .... you can add "set home=%homepath%\YourProEConfigs" in your batch file and have your users save theirown config.pro and config.win files there and ProE will also look in that folder for config files.
Edited by: kbrault
 
Ok, this is what my new batch file reads out as:


echo !ProE Search Path File >search.pro


del .\search.pro


dir /ad /s /b >search.tmp


@echo off


cls


for /f "Delims=" %%a in (search.tmp) do (


echo "%%a" >>search.pro


)


del ./search.tmp


"C:\Program Files\ProeWildfire 3.0\bin\proe.exe" %*


What happens now is that through windows explorer I have associated the ProE file type with this batch. This means if I click on the ProE icon it will start ProE normally using my config.pro file in the \text\ folder.


Now the bad, even doing this ProE will not find the search.pro file that is created. My assemblies still have to be located one part at a time. I have specified the working directory in the config file to be the active directory, I have included the search_file_path for the .\search.pro file. For whatever reason that I cannot determine, ProE will not find the assembly or parts.


Any Ideas at all now about what is causing this to happen? I have the above batch file, which by the way includes all file paths in "s just in case in the search.pro file. Is it the comment at the start of the file? I am just a little frustrated with this problem. Thanks for all of your help so far.


SEBNN
 
Ok, I figured out the one thing that I was missing here. The last line of my batch file looks as follows:


"c:\program files\ProeWildfire 3.0\bin\proe.exe" "c:\program files\ProeWildfire 3.0\bin\proe1.psf" %*


And the search_path_file reads as follows in my config file


search_path_file .\search.pro


And now it works like a charm! Thanks again for the help.
 
OK .. I think you are duplicating commands:


"echo !ProE Search Path File >search.pro" creates the search.pro file then "del .\search.pro" deletes it.


"dir /ad /s /b >search.tmp" dumps output to search.tmp then "for /f "Delims=" %%a in (search.tmp) do (echo "%%a" >>search.pro) re-reads it and dumps it to "search.pro" there is no value added here.


Remember ... none of this will work unless you have "search_path_file .\search.pro" in your "....\text\config.pro" file.


Try this:


dir /ad /s /b >search.pro
"C:\Program Files\ProeWildfire 3.0\bin\proe.bat" "%1"


Does the search.pro file appear in the folder where you double clicked the file? If so, do ANY of the folder names have a space in the them? Heck ... is there a space anywhere in this file? If so, then you will have to write a command to parse the folder name and replace all "\" with "\\".


If not try this:


for /f %%i in ("%1") do cd /d "%%~fi"
dir /ad /s /b >search.pro
"C:\Program Files\ProeWildfire 3.0\bin\proe.bat" "%1"


Note: You may have to research the exact syntax of the "if" line. I am trying to get the full folder name so we can change directories to it.


Does the search.pro file appear in the folder where you double clicked the file? If so, do ANY of the folder names have a space in the them? Heck ... is there a space anywhere in this file? If so, then you will have to write a command to parse the folder name and replace all "\" with "\\".


Kevin
Edited by: kbrault
 
I did the create and delete for fear that if the file is not there that it would give an error when it tries to delete it. If it won't give an error, then I can remove that line.


I am guessing you wrote this while I wrote my reply that I got it to work. Your suggestion to call .\bin\proe.bat is similar to what I did. I found that the bat file referenced two things while starting ProE and added the second to my bat file. I think however that your suggestion could be used to clean it up.


I do have the .\search.pro set as the value for the search_path_file setting. Anyways, it does work and in summary, to make it work do the following:


1) Using the "file types" under the "folders" under the "tools" menu in the windows explorer I set all proe type files to open with my run.bat program.


2) I wrote the run.bat program as described in my previous two posts and saved it in the proe\bin\ folder.


3) I did not change the reference under the shortcut for Proe to reference this run.bat file as I want ProE to open normally when I don't need to open a large assembly or am starting a new part.


4) I structure my assemblies, parts, and folders in a parent-child method. Parent folder is the top level, and sub-assemblies and parts go in subfolders.


5) I double click on the assembly I want to open and viola it is there!


Thanks again Kevin for your help with this
smiley32.gif
. I was not aware of the dir command being used in that way.
 
Good. Please post your completed batch file for everyone's benefit. Otherwise I think all you need is:


dir /ad /s /b >search.pro
"C:\Program Files\ProeWildfire 3.0\bin\proe.bat" "%1"


With "search_path_file .\search.pro" in your "config.pro" file and no spaces in any of the search paths.
 
Nice work Zestje,


What I do is create a RMB menu pick to the batch file. So you RMB on the folder you want to start ProE in and select "Start ProE".
 

Sponsor

Articles From 3DCAD World

Back
Top