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

Re: Mapkey Writing/Editing Tips

lockarde
7-Bedrock

Re: Mapkey Writing/Editing Tips

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`;\

1 ACCEPTED SOLUTION

Accepted Solutions

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`;

 

View solution in original post

13 REPLIES 13

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`;\

Thanks @lhoogeveen!  I'll mess around with and see if I can emulate that.  Ideally, the note would have two lines, top line at .375 height, and the next line at .188.  I was able to get the mapkey to do all of that, but it ended up being very long because it tracked every key stroke.  I will see if I can incorporate your method to pair it down and still get the text to resize like I want. 

I just noticed the "save Note" option, and thought, "Wow! You dummy, just save the note and have a mapkey pull that!"  Of course, none of the formatting gets saved, just the text.  Ugh

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!

I've used a mapkey to recall a saved note and then perform any minor formatting changes (if any) manually after inserting, however the pasting tip below may help in your situation.

 

A mapkey tip that may help is that instead of typing your text while the mapkey is recording, you can paste the text in and it won't show one letter at a time.  I also do this for opening locations or files rather than navigating to them.  Much easier to update later also if something changes.  

 

When needing multiple copy/paste in the same mapkey:

  • Have text open in another program (Notepad++, Word, email, etc), and just switch back and forth copying and pasting text. Creo  mapkeys don't register you switching between other programs.
  • Use the Win10 clipboard history, copy one line at a time then when pasting use the keyboard Win+V (instead of ctrl+V) and select the correct line.
  • Record just one paste, continue mapkey, save and manually edit the rest in your text editor (e.g. Notepad++).  Once you record this sliver then you can see the syntax in the config.pro and can manually adjust the text to your heart's content! 🙃

"When you reward an activity, you get more of it!"
Chris3
20-Turquoise
(To:LawrenceS)

Just to expand on @LawrenceS 's comment, there is a "note from file" when you place an unattached note. We have a mapkey that calls a vb script that generates a text file and then the mapkey places it on the drawing using absolute coordinates and the "note from file". Some formatting like special characters can be imported this way.

 

Chris3_0-1637583345440.png

 

@Chris3, I have seen VB/Visual Basic as an option in the Creo installation and it sounds potentially very useful.  But, unfortunately, I am not even sure where to begin with using it in a mapkey.  Can you share a mapkey and VB example of what you do &/or how you do this?


"When you reward an activity, you get more of it!"
Chris3
20-Turquoise
(To:LawrenceS)

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.

@Chris3  Thanks for the detailed explanation!  I understand now that you are using the mapkey to call up a script file and in this case that script file is type .vbs.  We have a few mapkeys that call up batch files, which seem to work pretty similarly, except it is a different language...I've also been trying to do more with Powershell.  I like your examples so thank you for taking the time to share them!

 

Is there a specific advantage with working with .vbs that other scripting languages are not as good at?  Or do you just write in because you are most familiar with .vbs?


"When you reward an activity, you get more of it!"
Chris3
20-Turquoise
(To:LawrenceS)

You can not as easily manipulate text files with batch scripts as you can with VBS. Its easier to structure and understand for and do while loops in VBS. I am not as familiar with powershell. VBS has been around since Windows 98 and powershell is relatively new.

 

VBS is structured very similar to VBA and since I use VBA as well I have always defaulted to VBS for OS scripts.

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.

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`;

 

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!

Top Tags