Sie sind auf Seite 1von 3

How do I set up Pro/ENGINEER for automation through an Excel file?

faq554-1254 Posted: 13 Jul 06 (Edited 28 Aug 07)

The point of this FAQ is to describe how you can drive Pro/Engineer using Excel... there is a good article on this that was published by Profiles Magazine (link below) that you will want to check out, but I have combined information from that article with other information I gleaned off of the Eng-Tips forum and my own experience implementing it to produce this FAQ. The key steps in setting up ProE for automation through an Excel file are: 1. 2. 3. 4. 5. 6. Create the model in ProE. Name dimensions. Edit the Pro/Program to include the dimensions named above. Create a tab-delimited text file with the dimensions named above. Create a trail file that regenerates the ProE model from the text file. Create an excel macro to run ProE using the trail file.

In ProE: 1) Create the model. 2) Name the dimensions you want to change (by right-clicking a dimension and going to Properties). 3) Edit the Pro/Program (in Wildfire 2.0 it is under Tools -> Program -> Edit Design): INPUT dimensionname1 number dimensionname2 number dimensionname3 number END INPUT See thread554-144905: Modify model in proe with text file for a more thorough discussion of this. In Excel: 4) Create a macro to save a tab-delimited text file with the names of the

dimensions on your ProE model that you want to modify (check out the excellent Profiles Magazine article on the entire process: Drive Your Pro/ENGINEER Model with a Spreadsheet). Enter values for the dimensions and save a tab-delimited file ("mydata.txt"). In ProE: 5) If you have ProEngineer open, close it. Open it again, open the file you want to modify and perform all of the actions that you would like to automate (including Edit -> Regnerate -> From File, and select the text file you generated from Excel). End by closing the file and exiting ProEngineer. Open windows explorer, find the trail file that was created, and rename it to "mytrailfile.txt" or something similar. In Excel: 6) Open the spreadsheet you created earlier. Create another macro (using the Visual Basic editor) that opens ProE in no graphics mode and run it from the trail file you created earlier. You are going to want to use the Visual Basic "Shell" command with the following: proe.exe -g:no_graphics mytrailfile.txt You can also set the relative path using Visual Basic "ChDir". Whatever relative path you set will determine the directory that ProE opens with as the default working directory. ProE will save trail files, etc, to this directory even if you change the working directory during your session. If the relative path is not the location of proe.exe, you will need to use the full filepath name to proe.exe (and possibly also to mytrailfile.txt, although it is easiest just to put the trail file wherever you will be setting the relative path to). There are some more tricks to it that you run into as you go along, but that is pretty much the jist of it. You can't use the 'save' command in the ProE trail file sequence, because if you overwrite a file that was opened, it is going to give you an error next time you run the trail file (I could be wrong on this one). So if you need to save you will need to save a copy instead. In my implementation of this, I am not saving the ProE file, I just save an eDrawing instead. If you don't have eDrawings installed, it is definitely worth a look, it is a very well-made program.

So far I have tried it on one other computer as well and it worked there, so the trail file is at least somewhat portable (both computers were PCs running Windows XP and Wildfire 2.0, I don't know yet what would happen if you try to use the same trail file on a different platform or a different version of ProE). Good luck! ------------------------------------------------------------------10/17/06 Update! I have continued to explore the possibility of driving Pro/Engineer from an external program. Recently I have begun to use "Jlink". The FAQ above describes how to drive Pro/Engineer using a trail file, but this method is not very robust due to the basic nature of a trail file. Using J-link is a much better alternative, however it is also a lot more work and requires knowledge of Java. To drive Pro/Engineer using J-link instead of a trail file, reuse steps 1-4 of this FAQ, but instead of creating a trail file in step 5, create a syncronous jlink program. See the j-link user's guide. You can find it in the directory where Pro/Engineer is installed, under a folder called "jlink", assuming that it was selected during the installation process. It is also available online. Good luck!!! 8/28/07 Update - Profiles Magazine just published an article titled "Developing Custom Pro/ENGINEER Applications using J-Link." Check it out: http://www.profilesmagazine.com/p39/felkins.html

Das könnte Ihnen auch gefallen