Community Tip - Your Friends List is a way to easily have access to the community members that you interact with the most! X
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`;\
Solved! Go to Solution.
Below mapkey:
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`;
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:
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, 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?
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?
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
¬e_1
¬e_2
Not a solution just more ways to get the mapkey plus other stuff to create what you want in the end.
Below mapkey:
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!