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.

parametric saving

waltter

New member
hi all


i was just wondering if there is any chance to make a mapkey which save my active drawing as a copy with name derived from a drawing parameter


e.g. i have drawing string parameter NAME with value (let' say)SOMETHING and that mapkey make a new drawing SOMETHING.drw


i think there is no way to do this straight but maybe by editing part of that mapkey in notepad could work. There exist some ph_model.ObjName() function (see below) which can retrive current model name.


mapkey cd ~ Select `main_dlg_cur` `MenuBar1`1 `File`;\
mapkey(continued) ~ Close `main_dlg_cur` `MenuBar1`;\
mapkey(continued) ~ Activate `main_dlg_cur` `File.psh_save_as`;\
mapkey(continued) ~ FocusOut `file_saveas` `ph_model.ObjName0`;



so if you know how to retrive any other parameter instead model name let me know...
smiley2.gif
 
You could do thiswith a mapkey that exports the param.inf file and calls an Autoit script.


Download Autoit from here:- http://www.autoitscript.com/


Then write an "Autoit"script to extract the required value.


Also use Autoit to put the value into the clipboard and send the proe commands to save a copy and then paste the value into the new name box.
 
Using 'paste' in a mapkey won't work, Pro|E records the paste operation as the actual text entered instead of 'paste'. In other words, in your example, if you copied 'SOMETHING' to the clipboard and pasted it in Pro|E, the mapkey would record that you entered the text 'SOMETHING' rather than you pasted the contents of the clipboard.


I'm not familiar with Autoit, however, if you're only concerned with the drawing name (and not the names of the models in the drawing), you could write a batch file (or perhaps use Autoit) to rename the file after it was saved.


In Pro|E, you'd do a save as of the drawing to a dummy name (the same name every time), export the parameter information to a file, use Autoit or a batch file to extract the parameter value and then rename the file.


Reliably extracting the parameter information for a drawing model can be tricky. If the drawing always has a single part or assy you should be fine. If there is sometimes more than one model on the drawing or sometimes a part and sometimes an assembly, getting Pro|E to spit out the parameter info for the right model can be challenging. Multi-model drawing are the hardest as Pro|E requires you to pick the model that you want to export the parameter info for.
 
You can make a mapkey that would select the Parameter pause and tell the user to copy it and activate Save as and tell the user to paste the copied parameter in.

Use the (Pause for keyboard input) option when creating the mapkey. Go to Parameters and select the Parameter so the value appears.

Hit the Pause Button and Mapkey recording will pause.
You will be prompted to enter an instruction for what to do at the pause.
Hit OK and then perform the copy yourself.
Hit Resume to record canceling out of the Parameters dialog and doing a File > Save As.

Then hit the Pause button and enter something like Please Paste the parameter in after current filename and hit Resume to continue.
Finish the Recording of the mapkey by hitting resume and hit OK button to perform the save as.

Now you'll have a Mapkey that allows the user to copy and paste the parameter needed to do your save as operation.

View attachment 4173

Michael
 
For Waltter and ayone else who is interested.


The following uses the description parameter as the new drawing name.



Mapkey to save a copy of drawing (Proe 2001):-


mapkey sc @MAPKEY_NAMESave Copy;@MAPKEY_LABELSave Copy;\
mapkey(continued) #ADVANCED;#PARAMETERS;#INFO;~ Activate `texttool` `CloseButton`;\
mapkey(continued) #DONE/RETURN@OBJ TYPES;#DONE/RETURN;\
mapkey(continued) @SYSTEMstart C:\\utils\\autoit\\proesavecopy.exe;


;Change above lin to the location of your autoit file



Compile the following Autoit Script:-
************************************************
; AutoIt Version: 3.0
; Language: English
; Platform: Win9x/NT
; Script Function:
; Proe save copy of drawing with parameter description as name


#include <file.au3>


AutoItSetOption ( "WinTitleMatchMode", 2 )


$paramfile = "C:\proe_start_folder\param.inf";Change to your proe default start folder
$paramname = "DESCRIPTION";Change DESCRIPTION to your parameter name
$paramvaluestartpos = 43;Start position of parameter value in param.inf


;Read param.inf into an array or exit if param.inf does not exist
Dim $value
If Not _FileReadToArray($paramfile, $value) Then
MsgBox(0 + 16, "Program Error", "Error reading " & $paramfile)
exit
EndIf


;Extract the new drawing name
For $i = 1 To $value[0]
$result = StringInStr($value[$i], $paramname)
If $result Then
$drawingname = StringMid($value[$i], $paramvaluestartpos, StringLen($value[$i]) - $paramvaluestartpos)
exitloop
EndIf
Next


WinActivate("Pro/ENGINEER")
Sleep(250)


Send("!fa") ;Using keyboard commands Select File, Save a Copy...


Send($drawingname) ;Put the drawing name into save copy dialog box


;Send("{ENTER}") ;Remove first character ";" to fully automate save copy
(Check drawing name is correct during testing)


exit
*************************************************
Do not include **** lines





As dgs points out, Proe cannot paste in mapkeys, but using Autoit you have a workaround.


Create a mapkey that calls an autoit script. In that script you can control proe with keyboard commands and use clipboard paste commands.


e.g To create a note copying from the clipboard


The script would be


WinActivate("Pro/ENGINEER")
Sleep(250)
Send("!in")
MouseClick("middle")


While 1
if _IsPressed("01") then ;waitfor left mouse button to indicate note position


exitloop


else
Sleep(100)
EndIf
Wend
Send("^v")
Send("{ENTER 2}")
 
doronron1:


That's sweet! I looked at AutoIT briefly when you first mentioned it, now I'm definitely giving it a shot.


Ironic that an external (free) program can make Pro|E ($$$$) do things (paste, middle mouse button) that Pro|E's built in mapkey functionality cannot.


Hello PTC?
 
@doronron1

Nice way to solve this with an AutoIt script.
AutoIt is great! I made a script with it which lets me choose between different projects and configs when I start ProE. It's not too difficult to learn and can do a LOT!
smiley32.gif
 

Sponsor

Articles From 3DCAD World

Back
Top