Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel driven PROE using trail file & Macro 2

Status
Not open for further replies.

avsp085

Automotive
Jan 9, 2014
2
HI,
I need help in using proE with Excel.
My requirement is

Copy part# from Excel/notepad
Open that drawing in PROE from server
Save it as PDF at specified folder
Close the File & open the next number listed in the Excel table.
Continue above steps in batch.

I heard that trail file & Excel macro combine would give the result but I am zero in programming so any help would be appreciated.

is anybody here to suggest for this ?

Thanks..
 
Replies continue below

Recommended for you

It's pretty easy, but that supposes that programming is easy. I'd recommend using AutoIT instead. It has commands like Sendkey to do the typing. I'd only use Excel if I was prevented from using AutoIT. Much the same way as I'd only use a spoon to dig a well if I couldn't use a drilling rig.

I've got the following outlines for both:

AutoIT method
Create a For..Next/Do Until to step through the names
Activate the ProE window
Sendkey to send the mapkey sequence to open a file
Wait for the Open File window
Send the filename and <CR>
Wait for the drawing to open
Send the mapkey sequence to print
Wait for the printing to be done
Send the mapkey sequence to close and erase.
Next/Until


Excel Method, assuming you are already good with VBA for Excel.
Start Pro/E so that there is a new trail file. Open a single file and perform all the steps you want. Include closing the file and erasing from memory. Then exit Pro/E. This will be the basic outline.

Some tips -
1) Type in the entire name rather than selecting it.
2) If you can, use mapkeys to drive Pro/E. This saves recording user errors and speeds making a new trail file if you did not get just what you wanted.

The trail file is just a text file and you can edit it with Notepad. It will at first appear to be unreadable - that's because you've had no practice.

The basic task is to create Print statements that create a new trail file, substituting the text from your Excel list for what's in the original trail file.

There's a section at the top that is the initialization for the trail file. If this isn't right the trail file won't run, so it needs to appear only once in the final resulting file.

At this point, I've sometimes wondered if using MS Word Mail Merge might not be easier for the non-programmer. However, at the end of Mail Merge, someone has to copy and paste the pieces back together to make a whole file.


As it is I created some utilities (if I find them I'll add them later) to read trail files and create the VBA program that prints them out again, which is most of the tedious work. Then a routine FOR .. EACH on the cells the names are in to wrap around the trail print statements; finally replacing the original trail file filenames with variables that are based on the FOR .. EACH loop.

If you change the name from trail.txt to training.txt (I think) Pro/E won't crash if there is an error. I'd have to look about the suffix to be certain, but it runs it as if for training use, where a user is expected to mess up and killing Pro/E would interfere with that learning.


Create a very simple trail file to start so that you can find the parts that you typed in.
 
Thanks dave. Appreciate your quick reply.


I haven't used autoIT yet but surely will try it.

For the Excel method, I was clueless how to integrate excel macro & trail file.


below is the trail file herewith for the steps you mentioned in PROE.

!trail file version No. 1400
!Pro/ENGINEER TM Wildfire 4.0 (c) 2014 by Parametric Technology Corporation All Rights Reserved.
< 0 1.347556 1549 0 0 1137 1920 0 0 1200 13
!mem_use INCREASE Blocks 158357, AppSize 36073485, SysSize 45101880
< 0 0.948000 948 0 0 997 1920 0 0 1200 13
< 0 1.124741 1303 0 0 949 1920 0 0 1200 13
< 0 1.124741 1239 0 0 949 1920 0 0 1200 13
< 0 1.124741 1197 0 0 949 1920 0 0 1200 13
< 0 1.117630 1197 0 0 943 1920 0 0 1200 13
~ Activate `main_dlg_cur` `main_dlg_cur`
!%CIWelcome to Pro/ENGINEER Wildfire 4.0.
< 0 1.117630 1196 0 0 943 1920 0 0 1200 13
< 0 1.138963 1568 0 0 961 1920 0 0 1200 13
~ Resize `main_dlg_cur` `main_dlg_cur` 4 -0.210175 -0.210175 44.837364 26.598832
~ Move `main_dlg_cur` `main_dlg_cur` 2 -0.210175 -0.210175
~ Activate `main_dlg_cur` `main_dlg_cur`
~ Activate `main_dlg_cur` `main_dlg_cur`
~ Activate `main_dlg_cur` `ProCmdModelOpen.file`
< 2 0.118519 178 0 0 100 1920 0 0 1200 13
~ Trail `UI Desktop` `UI Desktop` `DLG_PREVIEW_POST` `file_open`
~ Input `file_open` `Inputname` `5258864`
~ Input `file_open` `Inputname` `5258864.`
~ Input `file_open` `Inputname` `5258864.d`
~ Input `file_open` `Inputname` `5258864.dr`
~ Input `file_open` `Inputname` `5258864.drw`
~ Update `file_open` `Inputname` `5258864.drw`
~ Activate `file_open` `Open`
!Command ProCmdModelOpenExe was pushed from the software.
!09-Jan-14 15:09:53 Start wtpub://Windchill/Products/Military/Design/5258865.drw|01.2
!09-Jan-14 15:10:08 Start wtws://Windchill/suspension/5258865.prt
!09-Jan-14 15:10:08 End wtws://Windchill/suspension/5258865.prt
!09-Jan-14 15:10:08 Start wtws://Windchill/suspension/94_d-metric_pdm.frm
!09-Jan-14 15:10:08 End wtws://Windchill/suspension/94_d-metric_pdm.frm
!09-Jan-14 15:10:08 End wtpub://Windchill/Products/Military/Design/5258864.drw|01.2
!sket_eps 1.5
~ Activate `main_dlg_cur` `main_dlg_cur`
~ Timer `UI Desktop` `UI Desktop` `EmbedBrowserTimer`
~ Select `main_dlg_cur` `MenuBar1` 1 `File`
~ Close `main_dlg_cur` `MenuBar1`
~ Activate `main_dlg_cur` `File.psh_save_as`
~ Open `file_saveas` `type_option`
~ Close `file_saveas` `type_option`
~ Select `file_saveas` `type_option` 1 `db_617`
~ Activate `file_saveas` `desktop_pb`
~ Activate `file_saveas` `OK`
~ Select `intf_pdf` `pdf_color_depth` 1 `pdf_mono`
~ Select `intf_pdf` `PDFMainTab` 1 `PDFContent`
~ Select `intf_pdf` `pdf_font_stroke` 1 `pdf_stroke_all`
~ Activate `intf_pdf` `pdf_btn_ok`
!%CIPDF file is being created...
!%CIPDF file has been created.
~ Activate `main_dlg_cur` `main_dlg_cur`
~ Select `main_dlg_cur` `MenuBar1` 1 `Windows`
~ Close `main_dlg_cur` `MenuBar1`
~ Activate `main_dlg_cur` `Windows.psh_win_close`
!Command ProCmdWinClose was pushed from the software.
! Executed sub-command ProCmdWinCloseAsyn.
!%CIBase window cannot be closed.
~ LButtonArm `main_dlg_cur` `proe_win` 9 322 434 0 1025 1568 961 1920 1200 153193
** 0.094368 0.547347 0 1 1
0.094368 0.461824 L 0 1.138962963 0
~ LButtonDisarm `main_dlg_cur` `proe_win` 9 322 434 0 0 1568 961 1920 1200 153288
~ Minimize `main_dlg_cur` `main_dlg_cur`

 
The first step is creating a VBA program to read the trail file and turn it into useful print statements. I'm not sure where my old version of this went.

In any case - all the lines that end with a "\" are continued on the next line, so the program should remove that and join the lines.

~ Timer `UI Desktop` `UI Desktop` `EmbedBrowserTimer`

will become

~ Timer `UI Desktop` `UI Desktop` `EmbedBrowserTimer`

Then that result will end up as (check the help for how to print to a file)

PRINT "~ Timer `UI Desktop` `UI Desktop` `EmbedBrowserTimer`" in the VBA program.

The key items are:

~ Input `file_open` `Inputname` `5258864.drw`
~ Update `file_open` `Inputname` `5258864.drw`

You can skip the Input 'file_open' statments that precede these two lines. PTC records all the typing, but you only need the final Input and Update. These would become

PRINT "~ Input `file_open` `Inputname` `" & variable & ".drw`"
PRINT "~ Update `file_open` `Inputname` `" & variable & ".drw`"

where variable is the name of the drawing you want to open.


You can leave out any lines that start with a "!" (exclamation point) EXCEPT the first two.

The final program would look a bit like:
FILE OPEN "sample_trail.txt" as #1
PRINT #1, "!trail file version No. 1400"
PRINT #1, "!Pro/ENGINEER TM Wildfire 4.0 (c) 2014 by Parametric Technology Corporation All Rights Reserved."

FOR EACH filename IN filename_list
PRINT #1, ...
PRINT #1, ...

PRINT #1, "~ Input `file_open` `Inputname` `" & filename & ".drw`"
PRINT #1, "~ Update `file_open` `Inputname` `" & filename & ".drw`"

PRINT #1, ...
PRINT #1, ...

NEXT

CLOSE #1
 

A general, curious, intriguing query:

Where do you learn these things? How do you find out that something like this can be done and How do you explore the way to do it?


Regards

 
Reading and peeking and testing.

Reading: Some info is in documentation that comes (or used to) with the software.
Peeking: looking at what files contain.
Testing: In the case of trail files, seeing what can be removed without changing the outcome helps isolate the parts that are required. Repeating a task in Pro/E with some minor difference and comparing the trail files to see how that difference is recorded.

Other than that it is like putting puzzles together, look for parts and see what fits. Altogether, not difficult, just tedious.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor