Shortcut
Hey,
I want to create a keyboard shortcut that i can write in the command line to run the succession of these commands :
^C^C-layer;define;layer name;mline
I already create a shortcut button but i also want to create a keyboard shortcut
I don't want a keyboard shortcut with a format such as CTRL+.... but just want to tip a keyboard shortcut in the command lind such as running the line command with writting l in the command line
Comments
-
so you would do that in a lisp, we have hundreds of them.
command would be:
(DEFUN C:ML () (PRINC "\nMake Mline layer")(command "-layer" "m" "Mline" "") (princ))That makes ML as a command. Not sure how to run with Ctrl+, but not a great idea anyway IMO since that may involve menus.
Keep it to lisp to be simple.put that in a text file like Key-Ins.lsp, and load on startup.
You can load by hand with appload, or drag in from explorer, or add to On_doc_load_default.lsp.
The On_doc_load_default.lsp is the best way. Its just another text file, and put in a folder in your support paths.
It will load automatically when you open a drawing.
Once you do that, put the code above in it, instead of in Key-Ins.lsp.0 -
Tristan, you could do it by creating a lisp function and loading that. You wouldn't even need to create a shortcut for it in the Customize dialog box. You could just give the function a short name.
You define a new lisp function by using the (defun) function. Whatever comes right after the word defun is the name of the new function you're creating. Then you need an empty pair of parentheses, and then one or more other functions and their arguments, and then close the (defun) parentheses.
If you precede the name with c: the new function can be used on the command line without parentheses. Without the c: it can still be used on the command line, but you'd have to type parentheses around it to show it's a lisp function.
The thing you're trying to do needs the (command) function, and maybe the (sssetfirst) function.
(sssetfirst nil nil)
de-selects everything. The (command) function lets you use commands in a lisp function definition. The arguments to it are whatever you would type on the command line, but with quotes around each thing you'd type (but maybe not if they're numbers), and usually double quotes to represent Enter (though maybe not after option letters).In my system "define" is not an option of the -Layer command, but New is an option, and it doesn't take any sub-options. I assume you're trying to create a new layer called "mline". To do that on my system, I could type
-layer;n;mline;;
. To do that in lisp, I would use(command "-layer" "n" "mline" "")
Note that when I use the -layer command directly I need two Enters at the end and one after the N option, but to do it with lisp I must have only one at the end and none after N. I don't know why. To work with lisp you just have to experiment to see which peculiarity works in the present case. You can type a lisp function on the command line to experiment.The whole lisp function, for me, would be:
(defun c:ml () (sssetfirst nil nil) (command "-layer" "n" "mline" "") )
You just put that in a simple text file, using Notepad, but change the filename extension from .txt to .lsp. Or download the attached file. You might have to edit it to change to the option letters that your version of Bricscad accepts. Then use Bricscad's Appload command to load that file. Then you can type ML on the command line to create the layer.
0 -
If @Anthony Apostolaros hadn't typed so much, he would have beat me
This is like the old days on the adesk forums, competition! Of course your info is better Anthony...ok, its a draw.
I wanted to mention the -layer M option makes the layer and sets current. Slightly different than N for new, and N is better if you want to keep current layer.0 -
Actually, James, I'm a very fast typist, but a very slow code writer. It always takes me a long time to figure out how to do the simplest things in Lisp.
Maybe you can explain the rule about when you need double-quotes in the (command) function and when they make it just quietly not work? Lisp always seems so arbitrary and capricious to me. The only other programming I've done is assembly language, which is very predictable.
I don't understand why the forum didn't show me that you had already answered it. At the time I posted, there was nothing above the Leave a Comment box but the OP.
0 -
Hi James, Just a small note: end users should use on_doc_load.lsp (not on_doc_load_default.lsp, which is intended for the host application's use) for loading lisp code in every document.
0 -
Hi Owen,
I had no idea. I use On_start_default.lsp (blank) and On_doc_load_default.lsp currently.
I opened the file in support folder under install folder, and sure enough it says to not edit and to use what you said.
Thx for mentioning. It is interesting that those in support folder are blank.
Guess place holders for future.0