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.

Mapkey to retrieve drw file

jill.daniel

New member
Has anyone created a mapkey that will call up the dwg file that corrisponds with an active model(prt or assm). We don't have any extra data management programs like intralink, and I would like to be able to punch a few keys to bring up the drw that has the same name as the model only ending in .drw. (We have created all of our drawings with the same name as our models.) Any suggestions? I have tried creating a mapkey by retrieving the model info, and then using cut and paste in the open file menu and ending the name with .drw. The problem is that when I run the mapkey it always the same name calling up the same drw file (not unique to the model that is currently open)
thanks :)
 
When you have the part open, and in the active window -> file/new ->create a drawing file, name it whatever, usually the name of the part. This brings in the part automatically to the drawing. When the part is active and a new drawing file is made with the part active, the drawing will have the active part in it.





Otherwise if you wanted to add a part you have to rmb, model options, add model.
 
I'm sorry, I wan't clear on what I was talking about. I am not wanting to create the drawing. The drawing has already been created and is named that same as the part. The problem is that it is laborous to open a drawing by searching through the directory in the open file menu. I would like a mapkey that will open a drawing if I have the model open.
 
I don't know about the mapkey, but you know you could just type the name in the File Open window (not the fly-out browser) in the name field with an asteriks * (part_name*) at the end or justpart_name.drw
 
yes, thank you. I just wanted it to do it automatically. when I am working with an assembly there are several times i want to open up the corresponding drawing. It would just save me some time to be able to type in 3 or 4 letters and have the drawing come up. Thank you for your time though.
 
This is possible but not very elegant.


Create a mapkey to save as "tif" (Used for filename only. You may want to choose other type)
call a batch file to get filename and write to config.pro
load the config.pro
call another mapkey to open drawing


Note: The second mapkey (ii) will get duplicated in the config.pro.
Suggest you backup the config.pro before starting any work.
Restore config.pro after finishing with proe.


Worked ok in proe2001


my default proe directory is c:\temp
Change any lines with this in to your default proe directory


Add the mapkeys od and ii to c:\temp\config.pro


mapkey od @MAPKEY_NAMEopen drawing;@MAPKEY_LABELopen drawing;\
mapkey(continued) ~ 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) ~ Open `file_saveas` `type_option`;~ Close `file_saveas` `type_option`;\
mapkey(continued) ~ Select `file_saveas` `type_option`1 `db_563`;\
mapkey(continued) ~ Activate `file_saveas` `OK`;~ Activate `shd_img_param` `OK`;\
mapkey(continued) @SYSTEMstart c:\\temp\\drwopen.bat;\
mapkey(continued) ~ Select `main_dlg_cur` `MenuBar1`1 `Utilities`;\
mapkey(continued) ~ Close `main_dlg_cur` `MenuBar1`;\
mapkey(continued) ~ Activate `main_dlg_cur` `Utilities.psh_util_pref`;\
mapkey(continued) ~ FocusOut `preferences` `InputOpt`;~ Activate `preferences` `Open`;\
mapkey(continued) ~ Activate `file_open` `Open`;~ Activate `preferences` `ok`;%ii;



mapkey ii ~ Activate `main_dlg_cur` `ProCmdModelOpen.file`;\
mapkey(continued) ~ Activate `file_open` `Inputname` `yourdrawingname.drw`;\
mapkey(continued) ~ Activate `file_open` `Open`;






c:\temp\drwopen.bat


(copy lines between *****)
**********************
@echo off
::eek:pen proe drawing from prt or asm
::


for %%F in (*.tif) do set picname=%%F


set drwname=%picname:.tif=.drw%


del %picname%


>>c:\proe_temp\config.pro echo mapkey ii ~ Activate `main_dlg_cur` `ProCmdModelOpen.file`;\
>>c:\proe_temp\config.pro echo mapkey(continued) ~ Activate `file_open` `Inputname` `%drwname%`;\
>>c:\proe_temp\config.pro echo mapkey(continued) ~ Activate `file_open` `Open`;



exit
**********************
 
excellent solution, tnx.

doronron1 said:
This is possible but not very elegant.


Create a mapkey to save as "tif" (Used for filename only. You may want to choose other type)
call a batch file to get filename and write to config.pro
load the config.pro
call another mapkey to open drawing


Note: The second mapkey (ii) will get duplicated in the config.pro.
Suggest you backup the config.pro before starting any work.
Restore config.pro after finishing with proe......

Little add-on: to prevent this mapkey from filling up config.pro use this addition:

drwopen.bat:
****************
@echo off
::eek:pen proe drawing from prt or asm
::

for %%F in (*.tif) do set picname=%%F

set drwname=%picname:.tif=.drw%

del %picname%
copy c:\config\config.pro c:\config\config.bak

>>c:\config\config.pro echo mapkey ii ~ Activate `main_dlg_cur` `ProCmdModelOpen.file`;\
>>c:\config\config.pro echo mapkey(continued) @SYSTEMstart c:\\config\\restore.bat;\
>>c:\config\config.pro echo mapkey(continued) ~ Activate `file_open` `Inputname` `%drwname%`;\
>>c:\config\config.pro echo mapkey(continued) ~ Activate `file_open` `Open`;

exit
**********************

new file in the same dir:restore.bat
****************
@echo off
del c:\config\config.pro
copy c:\config\config.bak c:\config\config.pro
exit
****************

(c:\config\ is my default proE dir)
works like magic, have fun
smiley2.gif




Edited by: pavlok
 
Its Nice... I want to learn more about creating batch files... Can you please suggest some learning materials??


Navanee.
 
I can't get it to work. The script stops when it's supposed to change "yourdrawingname.drw" to the actual drawing name. In other words, Pro|E is trying to open the file yourdrawingname.drw.

I've copied the files above and changed to my default Pro|E directory. Have I forgotten something?

opendrw.bat:
Code:
@echo off
::open proe drawing from prt or asm
::

for %%F in (*.tif) do set picname=%%F

set drwname=%picname:.tif=.drw%

del %picname%
copy "c:\Program\proeWildfire 4.0\bin\config.pro" "c:\Program\proeWildfire 4.0\bin\config.bak"

>>"c:\Program\proeWildfire 4.0\bin\config.pro" echo mapkey ii ~ Activate `main_dlg_cur` `ProCmdModelOpen.file`;\
>>"c:\Program\proeWildfire 4.0\bin\config.pro" echo mapkey(continued) @SYSTEMstart "c:\\Program\\proeWildfire 4.0\\bin\\restore.bat";\
>>"c:\Program\proeWildfire 4.0\bin\config.pro" echo mapkey(continued) ~ Activate `file_open` `Inputname` `%drwname%`;\
>>"c:\Program\proeWildfire 4.0\bin\config.pro" echo mapkey(continued) ~ Activate `file_open` `Open`;


exit
config.pro:
Code:
mapkey od @MAPKEY_NAMEopen drawing;@MAPKEY_LABELopen drawing;\
mapkey(continued) ~ 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) ~ Open `file_saveas` `type_option`;~ Close `file_saveas` `type_option`;\
mapkey(continued) ~ Select `file_saveas` `type_option`1 `db_563`;\
mapkey(continued) ~ Activate `file_saveas` `OK`;~ Activate `shd_img_param` `OK`;\
mapkey(continued) @SYSTEMstart "c:\\Program\\proeWildfire 4.0\\bin\\drwopen.bat";\
mapkey(continued) ~ Select `main_dlg_cur` `MenuBar1`1 `Utilities`;\
mapkey(continued) ~ Close `main_dlg_cur` `MenuBar1`;\
mapkey(continued) ~ Activate `main_dlg_cur` `Utilities.psh_util_pref`;\
mapkey(continued) ~ FocusOut `preferences` `InputOpt`;~ Activate `preferences` `Open`;\
mapkey(continued) ~ Activate `file_open` `Open`;~ Activate `preferences` `ok`;%ii;
!-
mapkey ii ~ Activate `main_dlg_cur` `ProCmdModelOpen.file`;\
mapkey(continued) ~ Activate `file_open` `Inputname` `yourdrawingname.drw`;\
mapkey(continued) ~ Activate `file_open` `Open`;
restore.bat:
Code:
@echo off
del "c:\Program\proeWildfire 4.0\bin\config.pro"
copy "c:\Program\proeWildfire 4.0\bin\config.bak" "c:\Program\proeWildfire 4.0\bin\config.pro"
exit
 
@donron1: I have been trying for over 5 hours (!) to get this thing to work with a batch file, but finally gave up. The batch file assumes several things which often are not the case (e.g. diffent when working with Intralink or stand-alone ProE):
- it assumes the last dir a part was opened from is the same dir the part you want to open the drawing for is located in
- it assumes the .tif is saved to that same directory
- it assumes the last config settings file opened is config.pro
- several other problems

I have tried everyting to get it to work in all cases, e.g by passig the working dir to the batch file and using that informatin, but nothing makes it stable. There are too many variables (working dir, config dir, save dir for .tif, location of .drw to open), some of which cannot be captured by batch.


The weirdest thing is that the batch as I edited it actually fails to do some simple things like write a line to a file! The middle line below is simply NOT written at all most of the time, ony the 1st and 3rd line are:

>>h:\ProEFiles\config\Open_Drawing_02.pro echo mapkey z2 ~ Activate `main_dlg_cur` `ProCmdModelOpen.file`;\
>>h:\ProEFiles\config\Open_Drawing_02.pro echo mapkey(continued) ~ Activate `file_open` `Inputname` `%tifdir%\%drwname%`;\
>>h:\ProEFiles\config\Open_Drawing_02.pro echo mapkey(continued) ~ Activate `file_open` `Open`;

Also this simple rename operation below doesn't work in any way, even with/without quotes and/or path names:
ren h:\ProEFiles\config\Open_Drawing_02.pro.txt h:\ProEFiles\config\Open_Drawing_02.pro


These are some major batch handling problems, which should be impossible(!) and have nothing to do with your batch file, but made me pull out my hair!

I have had enough of this and will use a basic mapkey which uses the trick of creating a temporary drawing file and only requires the user to change .prt to .drw when prompted. I still hope I can find a way to get my own autoit script to always correctly activate ProE, because it -would- always work if it weren't for a Windows/ProE problem with activating windows.

The mapkey I use now is this one:

mapkey z2 ~ Command `ProCmdModelNew` ;~ Select `new` `Type`1 `Drawing`;\
mapkey(continued) ~ Input `new` `InputPanel1` `to_del`;~ Update `new` `InputPanel1` `to_del`;\
mapkey(continued) ~ Activate `new` `OK`;~ Activate `dwg_create` `psh_ok`;\
mapkey(continued) ~ Activate `open_instance` `open`;~ Command `ProCmdModelOpen`;\
mapkey(continued) ~ Trail `UI Desktop` `UI Desktop` `DLG_PREVIEW_POST` `file_open`;\
mapkey(continued) @MANUAL_PAUSEChange extension to .drw and press resume.;\
mapkey(continued) ~ Activate `file_open` `Open`;~ Command `ProCmdWinRadio` `TO_DEL.DRW.1`;\
mapkey(continued) ~ Select `main_dlg_cur` `MenuBar1`1 `File`;\
mapkey(continued) ~ Select `main_dlg_cur` `File.cb_file_erase`;\
mapkey(continued) ~ Close `main_dlg_cur` `MenuBar1`;\
mapkey(continued) ~ Close `main_dlg_cur` `File.cb_file_erase`;\
mapkey(continued) ~ Activate `main_dlg_cur` `psh_erase`;~ Activate `0_std_confirm` `OK`;
 
I have managed to get it working with a combination of a mapkey and an AutoIt script. For this I used GunnarHansen's Mapkey 'trick' as a basis:
http://www.mcadcentral.com/proe/forum/forum_posts.asp?TID=35 210&KW=filename&PN=0&TPN=1

One important thing I found out is that when a mapkey opens an external executable/batch files/vbs/whatever with @SYSTEMstart, the script immediately continues. It does not wait for the external program to finish. One i took hat into account It could fairly easily make a working AutoIt script. Once I have tested it (thoroughly) I will post it...
smiley17.gif


Edited by: Zestje
 
Hello again. Since it seems to be working well: here is the config.pro / AutoIt script combination to open a drawing with the same name as the part or assembly currently open/active.

2010-10-08_145011_Open_Drawing_M&S_v0.01.zip

Let me know what you think...

BTW: If you only want to use a mapkey and no script you can delete the line which point to the executable from the config (.pro) file. Then you must manually add the .drw and press resume.

<a href="uploads/Zestje/2010-10-08_145011_Open_Drawing_M&S_v0.01.zip" target="_blank">
</a>
 
Hi!


I created mapkeys in Creo 2 for opening drawing (with same name as part) of active part / assembly and one for creating new drawing with same name as active part/asm.



It is simple code in creo config.pro file and some in DOS file.


If somebody needs them, I can send this (I don't want to share it on internet yet; it is not tested enough and via e-mail I hope that I will get fedback about bugs - now after some tests works perfect ), my e-mail address:
49736_173_34_cache.jpg
 

Sponsor

Articles From 3DCAD World

Back
Top