Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X
Hi everyone,
i have a bunch of drawings with annotations, which have text between brackets. example: (hallo)
Now i want to delete all the brackets in all Annotations. example: hallo
So i tried to use mapkeys to save me time. But Creo doesn't record the keystroke (backspace or delete), which i use to get rid of the bracket, it records the undeleted text. When i use the mapkey Creo just records the text in the mapkey. Here is a Snippet out of the Mapkey for better understanding
mapkey(continued) ~ Command `ProCmdEditProperties@PopupMenuGraphicWinStack` ;\ mapkey(continued) ~ Update `note_text_asynch` `txt_note_text` `hallo)`;\ mapkey(continued) ~ FocusOut `note_text_asynch` `txt_note_text`;\
So my question is, how can i record keystrokes in an mapkey or is there another way to delete (semi-)automatic brackets around text in an annotation?!
Thank you!
Solved! Go to Solution.
You can do this using a vbs script called from a mapkey, see the post by GunnarHansen at https://community.ptc.com/t5/Creo-Modeling-Questions/How-do-I-get-a-prt-asm-name-into-a-mapkey/td-p/156122/page/2
As an example I have the following vbs script and mapkey which increases my crosshatch spacing by sqrt(2). I imagine it will be fairly easy to adapt to your use case
FILE PLUS.VBS --------------- Set Shell = CreateObject("WScript.Shell") Set WshShell = WScript.CreateObject("WScript.Shell")
Sub sk(command) WshShell.SendKeys(command) End Sub
sk "v{RIGHT}" 'v to activate 'value' and thn right sk "*sqrt{(}2{)}" sk "~" WScript.Quit()
CONFIG.PRO --------- mapkey ] @MAPKEY_LABELIncrease Xhatch;#SPACING;#OVERALL;\ mapkey(continued) @SYSTEM\start WScript.exe //B X:\\pathremoved\\plus.vbs;
What I have done for such things is to create an AutoIt program, though others may serve as well.
AutoIt can read from the ClipBoard that Windows uses and write back to the ClipBoard.
The process would be - open the note, copy the text, run the AutoIt program, and then paste the text. For advancement one can have AutoIt send the Copy and Paste commands and save the note, so open the note, run the AutoIt program and it's one shot.
Unfortunately Mapkeys don't have search and replace functions for string manipulations. It's really just a parrot function rather than a macro processor.
Here's an example program that replaces characters to place text copied from Excel into a Wiki table, ready for pasting. I'm sure other string replacement functions are possible, but was too lazy to try those. It adds "|" between each entry and a "||" at the beginning and end of all the pieces.
;From excel to TikiWiki
;The entry separators are tabs.
dim $excellines[20]
dim $tikiwiki = ""
$excel = ClipGet()
$excellines=StringSplit($excel,chr(13)&chr(10),1)
for $i=1 to $excellines[0]
$excellines[$i] = Stringreplace($excellines[$i],chr(9), "| ")
next
$excellines[1] = "||" & $excellines[1]
for $i=1 to $excellines[0]
if stringlen($excellines[$i]) <> 0 then
$tikiwiki = $tikiwiki & $excellines[$i] & chr(13) &chr(10)
endif
next
$tikiwiki = $tikiwiki & "||"
ClipPut($tikiwiki)
Thank you! That's a very useful answer! But unfortunately there is no way (for me) to install autoit or scripts of any kind on these workstation. Considering your answer i have to do the work manually.
Is Excel or Word installed? I expect the VBA modules for those apps can do a similar thing. I just prefer AutoIt because it isn't Excel or Word and so it doesn't have to load up a ton of application I don't need, and the programmng model is flatter so it's a bit quicker to get to doing what I want.
Excel VBA clipboard, for example: https://excelhelphq.com/how-to-read-or-access-the-clipboard-with-excel-vba/
There's also a PutInClipboard function.
You can do this using a vbs script called from a mapkey, see the post by GunnarHansen at https://community.ptc.com/t5/Creo-Modeling-Questions/How-do-I-get-a-prt-asm-name-into-a-mapkey/td-p/156122/page/2
As an example I have the following vbs script and mapkey which increases my crosshatch spacing by sqrt(2). I imagine it will be fairly easy to adapt to your use case
FILE PLUS.VBS --------------- Set Shell = CreateObject("WScript.Shell") Set WshShell = WScript.CreateObject("WScript.Shell")
Sub sk(command) WshShell.SendKeys(command) End Sub
sk "v{RIGHT}" 'v to activate 'value' and thn right sk "*sqrt{(}2{)}" sk "~" WScript.Quit()
CONFIG.PRO --------- mapkey ] @MAPKEY_LABELIncrease Xhatch;#SPACING;#OVERALL;\ mapkey(continued) @SYSTEM\start WScript.exe //B X:\\pathremoved\\plus.vbs;
yaeh that works great on my test environment. The problem that i now figured out is, our admins has block even execution of wscript with selfmade files on our production systems. Now i will talk with them 😉
Your answers helped me a lot! Thank you!