Skip to main content
12-Amethyst
November 11, 2021
Solved

Re: Mapkey Writing/Editing Tips

  • November 11, 2021
  • 3 replies
  • 5769 views

As per the original thread Does anyone know if it's possible to trim down NOTE mapkeys?  I'm not seeing the same format as say, a table input, so the option to cut every thing down using input / table_input doesn't seem applicable.  Thanks! Syntax for the NOTE that Creo recorded is below:

mapkey(continued) ~ Activate `main_dlg_cur` `page_Annotate_control_btn` 1;\
mapkey(continued) ~ Command `ProCmdDtlInsFreeNote` ;@PAUSE_FOR_SCREEN_PICK;\

mapkey(continued) ~ Key `main_dlg_cur` `proe_win` 9 183 -13 4259905 1536 2965 1134 1920 1080 \
mapkey(continued) 192499 `A`;\
mapkey(continued) ~ Key `main_dlg_cur` `proe_win` 9 183 -13 5439571 1536 2965 1134 1920 1080 \
mapkey(continued) 192499 `S`;\
mapkey(continued) ~ Key `main_dlg_cur` `proe_win` 9 183 -13 5439571 1536 2965 1134 1920 1080 \
mapkey(continued) 192499 `S`;\
mapkey(continued) ~ Key `main_dlg_cur` `proe_win` 9 183 -13 4522053 1536 2965 1134 1920 1080 \
mapkey(continued) 192499 `E`;\
mapkey(continued) ~ Key `main_dlg_cur` `proe_win` 9 183 -13 5046349 1536 2965 1134 1920 1080 \
mapkey(continued) 192499 `M`;\
mapkey(continued) ~ Key `main_dlg_cur` `proe_win` 9 183 -13 4325442 1536 2965 1134 1920 1080 \
mapkey(continued) 192499 `B`;\
mapkey(continued) ~ Key `main_dlg_cur` `proe_win` 9 183 -13 4980812 1536 2965 1134 1920 1080 \
mapkey(continued) 192499 `L`;\
mapkey(continued) ~ Key `main_dlg_cur` `proe_win` 9 183 -13 5832793 1536 2965 1134 1920 1080 \
mapkey(continued) 192499 `Y`;\

Best answer by BG_9869104

Below mapkey:

  1. opens a free note.
  2. pause for pick location.
  3. resume.
  4. edit the text height(could add other format edits). 
  5. uses "paste"(there is no real paste but I pasted in the text from windows clipboard to get a proper recording). Note the pasted text is "BigtestY\n" which is BigtestY + a return to get to next line.
  6. repeat step 4 to edit text format
  7. repeat step 5 but with new text input
  8. rinse and repeat as needed 

Im in metric so my text heights are 10, 6, and 4 in this example.

 

mapkey $F9 @MAPKEY_LABELmultisizenote;\
~ Command `ProCmdDtlInsFreeNote` ;\
@MANUAL_PAUSEPick Location;\
~ Command `ProCmdDtlSetTextHeight` 10.000000;\
~ Command `ProCmdEditPaste` ;\
~ Trail `UI Desktop` `UI Desktop` `TrailProcessEditPasteTextEdit` `BigtestY\n`;\
~ Command `ProCmdDtlSetTextHeight` 4.000000;\
~ Command `ProCmdEditPaste` ;\
~ Trail `UI Desktop` `UI Desktop` `TrailProcessEditPasteTextEdit` `smalLTesty\n`;\
~ Command `ProCmdDtlSetTextHeight` 6.000000;\
~ Command `ProCmdEditPaste` ;\
~ Trail `UI Desktop` `UI Desktop` `TrailProcessEditPasteTextEdit` `meDiumteSty\n`;\
~ Command `ProCmdDtlSetTextHeight` 4.000000;\
~ Command `ProCmdEditPaste` ;\
~ Trail `UI Desktop` `UI Desktop` `TrailProcessEditPasteTextEdit` `smalLTesty`;

 

3 replies

17-Peridot
November 11, 2021

Every Note area seems to be slightly different. I had to do a couple tricks to get 3D Notes/Annotations to get the mapkey to be cleaner/easier to edit. I typed in a character A, then ESC, and then I could access the right click 'properties' command. Kinda clunky but it works. The mapkey code below is with Creo 4 M150.

 

mapkey(continued) ~ Command `ProCmdUniEditProp@PopupMenuTree`;\
mapkey(continued) ~ Command `ProCmdDtlInsFreeNote`;@PAUSE_FOR_SCREEN_PICK;\
mapkey(continued) ~ Key `main_dlg_cur` `proe_win` 9 1257 139 4259905 512 1583 776 1920 1080 \
mapkey(continued) 582109 `A`;\
mapkey(continued) ~ Key `main_dlg_cur` `proe_win` 9 1237 249 65536 1536 1583 776 1920 1080 \
mapkey(continued) 1470518 `Esc`;\
mapkey(continued) ~ Command `ProCmdUniEditProp@PopupMenuGraphicWinStack`;\
mapkey(continued) ~ Update `note_3d` `sym_area_note_text` `ASSEMBLY`;\
mapkey(continued) ~ Activate `note_3d` `psh_ok`;\

lockarde12-AmethystAuthor
12-Amethyst
November 12, 2021

Well I am at a loss here.  If I type everything out and highlight the bottom row, change the text height, the mapkey records everything, and I can duplicate it that note over and over.  If instead, I use your method of typing A, then going into text editor, and change the note text that way, then go in and highlight text, change text height, it will not duplicate.  The mapkey is recording the same exact commands RE highlighting and changing text height, but instead of just doing the bottom row, it changes the entire note text height.  I even tried going into the note, typing a 1, backspace, then highlighting the text, to try and trick Creo into thinking I was typing the note..  can't get it to work!  Scratchin my head here, hoping someone has some insight into how I can get this to work without having a 100+ line mapkey!

Chris3
21-Topaz I
November 29, 2021

To be clear there is the VB Toolkit and then there are mapkeys. I am not using the VB Toolkit. I am using the OS command (@SYSTEM) that can be called from a mapkey. Below is an example of my typical structure with comments.

 

 

!=================================================================
!== Mapkey Name
!=================================================================
!Max number of characters per row is 80 although mapkey(continued) doesn't count
!2345678901234567890123456789012345678901234567890123456789012345678901234567890
!=================================================
!mapkey(continued)12345678901234567890123456789012345678901234567890123456789012345678901234567890

 

Header to make it easier to find the mapkey and know what it is. The lines below help you if you are manually editing the mapkey to make sure you don't go beyond the maximum number of characters per row

 

 

mapkey MapkeyABC123 @MAPKEY_LABELThis is the ToolTip;\

 

MapkeyABC123 is what the user needs to type in and or select from the mapkey dialog box. "This is the ToolTip" is the description that shows up if you hover over the mapkey with your mouse.

 

mapkey(continued) @SYSTEMC:\\NetworkPath\\Folder1\\Script.VBS;\

This is how you call a Visual Basic script from a mapkey. Typically this script deletes any left over files from the previous session or if the mapkey failed for some reason and left files behind. It also creates a config.pro file that can be read in the next block of the mapkey code.

 

mapkey(continued) ~ Select `main_dlg_cur` `appl_casc`;\
mapkey(continued) ~ Close `main_dlg_cur` `appl_casc`;~ Command `ProCmdRibbonOptionsDlg` ;\
mapkey(continued) ~ Select `ribbon_options_dialog` `PageSwitcherPageList` 1 `ConfigLayout`;\
mapkey(continued) ~ Select `ribbon_options_dialog` `ConfigLayout.ImportExportBtn`;\
mapkey(continued) ~ Close `ribbon_options_dialog` `ConfigLayout.ImportExportBtn`;\
mapkey(continued) ~ Activate `ribbon_options_dialog` `ConfigLayout.Open`;\
mapkey(continued) ~ Trail `UI Desktop` `UI Desktop` `DLG_PREVIEW_POST` `file_open`;\
mapkey(continued) ~ Activate `file_open` `file_open`;\
mapkey(continued) ~ Update `file_open` `Inputname` `C:\\Folder1\\mapkey_config.pro`;\
mapkey(continued) ~ Activate `file_open` `Inputname`;\
mapkey(continued) ~ Activate `ribbon_options_dialog` `OkPshBtn`;\
mapkey(continued) ~ FocusIn `UITools Msg Dialog Future` `no`;\
mapkey(continued) ~ Activate `UITools Msg Dialog Future` `no`;\

This block runs File-> Options -> Configuration Editor -> Import / Export -> Import configuration file with the path to a config file. In my case the VBS script that was previously called writes a config.pro text file.

 

mapkey(continued) %TempMapkey123;\

This is a temporary mapkey that is contained within the config.pro that the VB script wrote out. This line runs that mapkey.

 

mapkey(continued) ~ Command `ProCmdUtilMacros`;\
mapkey(continued) ~ Select `mapkey_main` `list_mapkeys` 1 `TempMapkey123`;\
mapkey(continued) ~ Activate `mapkey_main` `DeleteButton`;\
mapkey(continued) ~ Activate `mapkey_main` `CloseButton`;\
mapkey(continued) ~ Command `ProCmdOaDeselectAll`;

This block selects and deletes the previously run temporary mapkey from the list of mapkeys. The last line deselects anything left selected.

 

All together it looks like this:

mapkey MapkeyABC123 @MAPKEY_LABELThis is the ToolTip;\
mapkey(continued) @SYSTEMC:\\NetworkPath\\Folder1\\Script.VBS;\
mapkey(continued) ~ Select `main_dlg_cur` `appl_casc`;\
mapkey(continued) ~ Close `main_dlg_cur` `appl_casc`;~ Command `ProCmdRibbonOptionsDlg` ;\
mapkey(continued) ~ Select `ribbon_options_dialog` `PageSwitcherPageList` 1 `ConfigLayout`;\
mapkey(continued) ~ Select `ribbon_options_dialog` `ConfigLayout.ImportExportBtn`;\
mapkey(continued) ~ Close `ribbon_options_dialog` `ConfigLayout.ImportExportBtn`;\
mapkey(continued) ~ Activate `ribbon_options_dialog` `ConfigLayout.Open`;\
mapkey(continued) ~ Trail `UI Desktop` `UI Desktop` `DLG_PREVIEW_POST` `file_open`;\
mapkey(continued) ~ Activate `file_open` `file_open`;\
mapkey(continued) ~ Update `file_open` `Inputname` `C:\\Folder1\\mapkey_config.pro`;\
mapkey(continued) ~ Activate `file_open` `Inputname`;\
mapkey(continued) ~ Activate `ribbon_options_dialog` `OkPshBtn`;\
mapkey(continued) ~ FocusIn `UITools Msg Dialog Future` `no`;\
mapkey(continued) ~ Activate `UITools Msg Dialog Future` `no`;\
mapkey(continued) %TempMapkey123;\
mapkey(continued) ~ Command `ProCmdUtilMacros`;\
mapkey(continued) ~ Select `mapkey_main` `list_mapkeys` 1 `TempMapkey123`;\
mapkey(continued) ~ Activate `mapkey_main` `DeleteButton`;\
mapkey(continued) ~ Activate `mapkey_main` `CloseButton`;\
mapkey(continued) ~ Command `ProCmdOaDeselectAll`;

 

Here is an example of what the VBS looks like:

'****************************************************
' Header '
'***************************************************'
'-----------variables---------------------------
Option Explicit
Dim objFSO, objShell, objFile, i
Dim strFile, strConfigFile, strTempDirectory, strTextAll
Dim ConfigPro

strTempDirectory = "C:\Folder"
strFile = "\TextFile.txt"
strConfigFile = "\mapkey_config.pro"

'---------- Create the File System Object ---------------------
Set objFSO = CreateObject("Scripting.FileSystemObject")

'--------- Check if File Exists----------------------------
If objFSO.FileExists(strTempDirectory & strFile) Then

'Create variable to hold config.pro file
Set ConfigPro = objFSO.CreateTextFile(strTempDirectory & strConfigFile, True)

Set objFile= objFSO.OpenTextFile(strTempDirectory & strFile, 1)
' Read all lines in ...
strTextAll = Split(objFile.ReadAll, vbCrLf)

For i = 1 To 2

	'Do something here
	
		ConfigPro.WriteLine("mapkey(continued) ~ Command;") 
		ConfigPro.Close
		
Next
objFile.Close
	

Else
WScript.Echo "File " & strFile " does not exist in " & strTempDirectory & " Program will end."
End If 

'---------End Error Checking script------------
set objFile = nothing

In this case it opens a text file created by Creo, does something with it, writes a config.pro file and then closes.

14-Alexandrite
November 16, 2021

Another tool that may be useful is stuffing all the text into separate parameters or in not displayed notes added to the model tree. The text then can be brought in with the &. 

&bigtexttitleline
&smallertext

 

&note_1

&note_2

Not a solution just more ways to get the mapkey plus other stuff to create what you want in the end.

14-Alexandrite
November 17, 2021

Below mapkey:

  1. opens a free note.
  2. pause for pick location.
  3. resume.
  4. edit the text height(could add other format edits). 
  5. uses "paste"(there is no real paste but I pasted in the text from windows clipboard to get a proper recording). Note the pasted text is "BigtestY\n" which is BigtestY + a return to get to next line.
  6. repeat step 4 to edit text format
  7. repeat step 5 but with new text input
  8. rinse and repeat as needed 

Im in metric so my text heights are 10, 6, and 4 in this example.

 

mapkey $F9 @MAPKEY_LABELmultisizenote;\
~ Command `ProCmdDtlInsFreeNote` ;\
@MANUAL_PAUSEPick Location;\
~ Command `ProCmdDtlSetTextHeight` 10.000000;\
~ Command `ProCmdEditPaste` ;\
~ Trail `UI Desktop` `UI Desktop` `TrailProcessEditPasteTextEdit` `BigtestY\n`;\
~ Command `ProCmdDtlSetTextHeight` 4.000000;\
~ Command `ProCmdEditPaste` ;\
~ Trail `UI Desktop` `UI Desktop` `TrailProcessEditPasteTextEdit` `smalLTesty\n`;\
~ Command `ProCmdDtlSetTextHeight` 6.000000;\
~ Command `ProCmdEditPaste` ;\
~ Trail `UI Desktop` `UI Desktop` `TrailProcessEditPasteTextEdit` `meDiumteSty\n`;\
~ Command `ProCmdDtlSetTextHeight` 4.000000;\
~ Command `ProCmdEditPaste` ;\
~ Trail `UI Desktop` `UI Desktop` `TrailProcessEditPasteTextEdit` `smalLTesty`;

 

lockarde12-AmethystAuthor
12-Amethyst
November 22, 2021

Thank you @BG_9869104 !  This worked perfectly - changed the text to match what I wanted and it performs exactly like I want.  Trimmed my map key down from ~73 lines to 9!