cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

Map key to open drawing with the same name as the model

zrehlander
1-Newbie

Map key to open drawing with the same name as the model

Hey everyone,

I have searched through some of the discussion but I don't really understand the code that has been thrown around. I have three map keys set up in my config file. The first is ft and that opens my family table. The second is od and that opens my drawing and gives me a front cross section view, a right view, and then an iso view in the top right corner, I then pause to pick my instance and fill is my prompts such as details, date, drawn, by, part number, etc. I then use d to open the dimension tool and dimension the drawing. My question is how to I get my drawing file to open and be saved as the same name as the model file through my map keys so I don't have to go in and rename every drawing that I do? I tried to follow some peoples codes and put them in my map key code but then everything messed up. I also would like to get my drawing number box in the title block to be the same name as what the drawing and model are named. I'll attach a copy of the map key code I am running at the moment. Any help would be greatly appreciated because I'm pretty lost right now.

mapkey od @MAPKEY_LABELopen drawing;\

mapkey(continued) ~ Activate `main_dlg_cur` `ProCmdModelNew.file`;\

mapkey(continued) ~ Activate `new` `chk_use_default_template`0

mapkey(continued) ~ Select `new` `Type`1  `Drawing`;~ Activate `new` `OK`;\

mapkey(continued) ~ Select `dwg_create` `rad_format`1  `1`;\

mapkey(continued) ~ Select `dwg_create` `lst_template_names`1  `fam_table_4`;\

mapkey(continued) ~ Activate `dwg_create` `psh_ok`;~ Activate `open_instance` `open`;;;;;;;;;;;\

mapkey(continued) ;~ Activate `main_dlg_cur` `ProCmdDwgShowErase.dwg`;@PAUSE_FOR_SCREEN_PICK;\

mapkey(continued) @PAUSE_FOR_SCREEN_PICK;~ Activate `GET SELECT` `done_sel`;\

mapkey(continued) ~ Activate `showerase` `psh_accept_all`;@PAUSE_FOR_SCREEN_PICK;\

mapkey(continued) @PAUSE_FOR_SCREEN_PICK;@PAUSE_FOR_SCREEN_PICK;@PAUSE_FOR_SCREEN_PICK;\

mapkey(continued) @PAUSE_FOR_SCREEN_PICK;@PAUSE_FOR_SCREEN_PICK;@PAUSE_FOR_SCREEN_PICK;\

mapkey(continued) ~ Activate `showerase` `psh_close`;\

mapkey(continued) ~ Timer `UI Desktop` `UI Desktop` `popupMenuRMBTimerCB`;\

mapkey(continued) ~ Close `rmb_popup` `PopupMenu`;~ Activate `rmb_popup` `DwgPopupErase`;

mapkey ft @MAPKEY_LABELFamily Table;\

mapkey(continued) ~ Select `main_dlg_cur` `MenuBar1`1  `Utilities`;\

mapkey(continued) ~ Close `main_dlg_cur` `MenuBar1`;\

mapkey(continued) ~ Activate `main_dlg_cur` `Utilities.psh_famtab`;

mapkey od @MAPKEY_LABELopen drawing;\

mapkey(continued) ~ Select `main_dlg_cur` `MenuBar1`1  `Utilities`;\

mapkey(continued) ~ Close `main_dlg_cur` `MenuBar1`;\

mapkey(continued) ~ Activate `main_dlg_cur` `Utilities.psh_famtab`;@MANUAL_PAUSEgo;\

mapkey(continued) ~ Activate `ftb_edit_table` `OK`;\

mapkey(continued) ~ Activate `main_dlg_cur` `ProCmdModelNew.file`;\

mapkey(continued) ~ Select `new` `Type`1  `Drawing`;\

mapkey(continued) ~ Activate `new` `chk_use_default_template`0 ;~ Activate `new` `OK`;\

mapkey(continued) ~ Select `dwg_create` `rad_format`1  `1`;\

mapkey(continued) ~ Select `dwg_create` `lst_template_names`1  `fam_table_4`;\

mapkey(continued) ~ Activate `dwg_create` `psh_ok`;~ Activate `open_instance` `open`;;;;;;;;;;;\

mapkey(continued) ;~ Activate `main_dlg_cur` `ProCmdDwgShowErase.dwg`;

mapkey od @MAPKEY_LABELopen drawing;\

mapkey(continued) ~ Activate `main_dlg_cur` `ProCmdModelNew.file`;\

mapkey(continued) ~ Select `new` `Type`1  `Drawing`;\

mapkey(continued) ~ Activate `new` `chk_use_default_template`0 ;~ Activate `new` `OK`;\

mapkey(continued) ~ Select `dwg_create` `rad_format`1  `1`;\

mapkey(continued) ~ Select `dwg_create` `lst_template_names`1  `fam_table_4`;\

mapkey(continued) ~ Activate `dwg_create` `psh_ok`;~ Activate `open_instance` `open`;;;;;;;;;;;\

mapkey(continued) ;~ Activate `main_dlg_cur` `ProCmdDwgShowErase.dwg`;

mapkey d @MAPKEY_LABELdimension;\

mapkey(continued) ~ Activate `main_dlg_cur` `ProCmdDwgShowErase.dwg`;@PAUSE_FOR_SCREEN_PICK;\

mapkey(continued) @PAUSE_FOR_SCREEN_PICK;~ Activate `GET SELECT` `done_sel`;\

mapkey(continued) @PAUSE_FOR_SCREEN_PICK;@PAUSE_FOR_SCREEN_PICK;\

mapkey(continued) ~ Activate `showerase` `psh_close`;

mapkey od @MAPKEY_LABELOpen Drawing;\

mapkey(continued) ~ Activate `main_dlg_cur` `ProCmdModelNew.file`;\

mapkey(continued) ~ Select `new` `Type`1  `Drawing`;\

mapkey(continued) ~ Activate `new` `chk_use_default_template`0 ;~ Activate `new` `OK`;\

mapkey(continued) ~ Select `dwg_create` `rad_format`1  `1`;\

mapkey(continued) ~ Select `dwg_create` `lst_template_names`1  `fam_table_4`;\

mapkey(continued) ~ Activate `dwg_create` `psh_ok`;~ Activate `open_instance` `open`;;;;;;;;;;;\

mapkey(continued) ;~ Activate `main_dlg_cur` `ProCmdDwgShowErase.dwg`;\

mapkey(continued) ~ Activate `main_dlg_cur` `ProCmdDwgLockViewMovement.dwg`0;

mapkey od @MAPKEY_LABELOpen Drawing;\

mapkey(continued) ~ Activate `main_dlg_cur` `ProCmdModelNew.file`;\

mapkey(continued) ~ Select `new` `Type`1  `Drawing`;\

mapkey(continued) ~ Activate `new` `chk_use_default_template`0 ;~ Activate `new` `OK`;\

mapkey(continued) ~ Select `dwg_create` `rad_format`1  `1`;\

mapkey(continued) ~ Select `dwg_create` `lst_template_names`1  `fam_table_4`;\

mapkey(continued) ~ Activate `dwg_create` `psh_ok`;~ Activate `open_instance` `open`;;;;;;;;;;;\

mapkey(continued) ;~ Activate `main_dlg_cur` `ProCmdDwgShowErase.dwg`;@PAUSE_FOR_SCREEN_PICK;

mapkey od @MAPKEY_LABELOpen Drawing;\

mapkey(continued) ~ Move `main_dlg_cur` `main_dlg_cur`2 0.596849 1.141798

mapkey(continued) ~ Activate `main_dlg_cur` `ProCmdModelNew.file`;\

mapkey(continued) ~ Select `new` `Type`1  `Drawing`;\

mapkey(continued) ~ Activate `new` `chk_use_default_template`0 ;~ Activate `new` `OK`;\

mapkey(continued) ~ Select `dwg_create` `rad_format`1  `1`;\

mapkey(continued) ~ Select `dwg_create` `lst_template_names`1  `fam_table_4`;\

mapkey(continued) ~ Activate `dwg_create` `psh_ok`;

mapkey d ~ Activate `main_dlg_cur` `ProCmdDwgShowErase.dwg`;\

mapkey(continued) ~ Activate `showerase` `chk_dim`0 ;~ Activate `showerase` `chk_dim`1

mapkey(continued) ~ Move `GET SELECT` `GET SELECT`2 44.737720 12.871177;

mapkey d ~ Activate `main_dlg_cur` `ProCmdDwgShowErase.dwg`;\

mapkey(continued) ~ Activate `showerase` `chk_dim`0 ;~ Activate `showerase` `chk_dim`1

mapkey(continued) ~ Move `GET SELECT` `GET SELECT`2 44.737720 12.871177;

1 ACCEPTED SOLUTION

Accepted Solutions
Chris3
20-Turquoise
(To:zrehlander)

Mapkeys are not dynamic. They can only record what you click and what you type. If your file save as input is ABC.drw, that gets written into the Mapkey. The best you can do is insert a manual pause and enter it yourself. If you want more than that you need to use one of the APIs.

View solution in original post

16 REPLIES 16

just noticed this but the is really a ; \ but without the space. not sure if that matters or not.

Chris3
20-Turquoise
(To:zrehlander)

Mapkeys are not dynamic. They can only record what you click and what you type. If your file save as input is ABC.drw, that gets written into the Mapkey. The best you can do is insert a manual pause and enter it yourself. If you want more than that you need to use one of the APIs.

Thank You, that is giving me what I want.

On occasion, to avoid typos when creating a drawing with the same name as the model I have:

  • gone to File Rename (or wherever it now hides in Creo;
  • copied the model name to clipboard;
  • cancelled out of the Rename;
  • started the New Drawing creation;
  • pasted the name into the New Drawing dialogue box.

If mapkeys support copy and paste, perhaps this technique could be adapted?


@JonathanHodgson wrote:

On occasion, to avoid typos when creating a drawing with the same name as the model I have:

 

  • gone to File Rename (or wherever it now hides in Creo;
  • copied the model name to clipboard;
  • cancelled out of the Rename;
  • started the New Drawing creation;
  • pasted the name into the New Drawing dialogue box.

 

If mapkeys support copy and paste, perhaps this technique could be adapted?


Mapkeys doesn't support copy and paste, unfortunately.

llie
16-Pearl
(To:acvale)

Look at my attached zip. It works really good. We created a mapkey to run the script.

But, what is an API and how do those work / what do they offer?

Chris3
20-Turquoise
(To:zrehlander)

The APIs are programming interfaces to the Creo environment. They allow you to write code to control Creo. If you don't know how to code they are probably not for you. If you do know how to write code they still may not be for you. They are not well documented and there are not a ton of examples out there. More info in this thread:

J-link, Toolkit, Web.Link?? Help!

ChrisPLM
9-Granite
(To:Chris3)

Just to add to the discussion.

Mapkeys are already mentioned are just to record what you do with the mouse more or less but you can link a mapkey to some code.

We had this issue in the past where users kept by passing our master data governance and name the drawing with the partnumber instead of given it a name and the model name was the partnumber too instead of the model name. Why they were doing that ? because they could sort their workspace by Name and have together the model and the drawing.....  We have found that there was no easy/direct way to open the drawing from the model in the workspace so we develop a Weblink tool links to a mapkey. When user had a model open and wanted now to see its drawing, he just needed to press the mapkey. The code was seeking for the drawing (even if the drawing was not in the workspace) and opened it.

For the users it looked like a mapkey but it was not, the mapkey was just calling the weblink script.

This was developed by my support team and not any users. As Christopher said such tools are not for everyone.....

Jose_Costa
6-Contributor
(To:zrehlander)

The mapkeys you posted are a real mess. First you have to first take some time to learn how to deal with them.

Using some programming may be the best solution, maybe J-Link?

I cleaned up a "little" the mapkey but I doubt it will work in your computer, but we never know. Copy the mapkeys from the attached file and paste it in your config.pro.

Then restart Creo, open your generic part and call mapkey "ft".

With family tables you can replace the model of the drawing with another instance.

So you can create the drawing of the generic, and then create copies and replace the models. Find Here a script that automate this.

Hope it helps.

Jose

Thank you. Yeah as you caught on, I have no idea what I'm doing with the map keys but they were working so I went with it. yours did open a drawing on mine but it didn't change the name to the model part. Thank you for trying though. I ended up just putting a manual pause in and typing in the drawing name and then in the drawing name box of the title block used the &dwg_name so it automatically loads it like that.

I did something similar zrehlander but you just have to press ctrl + V when it pauses to input the title:

 

This is my somewhat work around which allows you to create a new 2D drawing using the same part number.

 

Because Creo doesn't like pasting what's in your clipboard on the new filename section, the only thing you will have to do is press Ctrl+V and enter when prompted to enter a drawing name. The macro creates a parameter called CAD_NUMBER which is essentially your model_name but allows a place to copy the name, then create a new drawing, it then pauses at the filename stage, you press Ctrl+V then enter, and finish your drawing format preferences.

 

Type 'ndwg' when you're on your part you want to create a new drawing for.

mapkey ndwg @MAPKEY_LABELCreate New 2D dwg with same name;~ Command `ProCmdMmRels` ;\
mapkey(continued) ~ Update `relation_dlg` `RelText` 1 27 54 1 `\nCAD_NUMBER=rel_model_name()`;\
mapkey(continued) ~ Activate `relation_dlg` `PB_OK`;~ Command `ProCmdMmParams` ;\
mapkey(continued) ~ Select `relation_dlg` `ParamsPHLay.ParTable` 2 `rowCAD_NUMBER` `value`;\
mapkey(continued) ~ RButtonArm `relation_dlg` `ParamsPHLay.ParTable` 2 `rowCAD_NUMBER` `value`;\
mapkey(continued) ~ PopupOver `relation_dlg` `ParamsPHLay.ParamUtils` 1 `ParamsPHLay.ParTable`;\
mapkey(continued) ~ Open `relation_dlg` `ParamsPHLay.ParamUtils`;\
mapkey(continued) ~ Close `relation_dlg` `ParamsPHLay.ParamUtils`;\
mapkey(continued) ~ Activate `relation_dlg` `ParamsPHLay.PBCopy`;\
mapkey(continued) ~ Activate `relation_dlg` `PB_OK`;~ Command `ProCmdModelNew` ;\
mapkey(continued) ~ Select `new` `Type` 1 `Drawing`;\
mapkey(continued) ~ Activate `new` `chk_use_default_template`0 ;\
mapkey(continued) %partnamenew;\
mapkey(continued) @MANUAL_PAUSEName drawing and Resume.;\
mapkey(continued) ~ Activate `new` `OK`;\
mapkey(continued) ~ Select `dwg_create` `rad_format` 1 `2`;\
mapkey(continued) ~ Activate `dwg_create` `psh_format_browse`;\
mapkey(continued) ~ Trail `UI Desktop` `UI Desktop` `DLG_PREVIEW_POST` `file_open`;\
mapkey(continued) ~ Select `file_open` `Ph_list.Filelist` 1 `shanen_format_a3.frm`;\
mapkey(continued) ~ Trail `UI Desktop` `UI Desktop` `PREVIEW_POPUP_TIMER` \
mapkey(continued) `file_open:Ph_list.Filelist:<NULL>`;\
mapkey(continued) ~ Command `ProFileSelPushOpen_Standard@context_dlg_open_cmd`;

 

Hope this helps.

All,

 

A super user created a very small autoit file that is then made into an .exe that does exactly what your looking for and the best thing is you do not need to update the mapkey every revision. I can give you the original which is only 3k in size and then you have a makpey call out the .exe.

 

Quickly open drawing related to the active Creo model (part/assembly only). It searches your current Workspace and then Commonspace. We customized it to do the following:

 

X123456-1.prt will open X123456.drw

X123460-1.asm will open X123460.drw

X123460-2.asm will open X123460.drw

 

A123456.asm  opens A123456.drw

 

787946-100.asm will open 787946-100.drw (not 787946-200.drw or 787946-500.drw)

787946-200.asm will open 787946-200.drw

787946-500.asm will open 787946-500.drw

 

If no drw exists:

Displays Creo, File, Open dialog box with name of part/asm in the search field

TomU
23-Emerald IV
(To:llie)

Can you attach it as a zip file to this discussion?

llie
16-Pearl
(To:TomU)

The original was written in czech and we had to translate it and make sure it doesn't leak info out.
It searches for the drawing with the same number as the model in the active Creo window. I included the mapkey that calls out the .exe. Only thing you need to do is make sure you place the exe in the path that is called out in the mapkey.

Top Tags