command alias

I made an own tool for the command _fillet;r;0 which works fine.
Now I wanted to have a keyboardshortcut for this command.
I tried with putting the command (command "_fillet" "r" "0") into an aliasname e.g. for "n".
Pressing "n" I can see in the commandline that Bricscad uses the command but ends up with "0nil" and not giving me the chance to choose the first line for the fillet command. See attached screenshots.

Can anybody help?

Thanx in advance,

Sascha

Comments

  • Sascha, I don't know whether you can assign a keyboard shortcut to a script. I have never been able to do that.
    But I know you can create a custom command using lisp, and put it in an automatic-loading file, and then you can assign a shortcut to that.
    Also, I've had trouble using the Fillet command in lisp the way you did it. In order to set the radius and also make a fillet, I've had to execute the command twice. I don't know why. Maybe I'm misunderstanding something.
    [code](defun c:FilletZero ()
    (command "fillet" "r" "0")
    (command "fillet" pause pause)
    )[/code]
    If you do it that way you don't need a shortcut. You can give the command a short name in the lisp code -- you can use c:N instead of c:FilletZero.
  • You could try this:
    [code](defun c:n (/ old_cmdecho old_filletrad)
      (setq old_cmdecho (getvar "cmdecho"))
      (setq old_filletrad (getvar "filletrad"))
      (setvar "filletrad" 0.0)
      (setvar "cmdecho" 1)
      (command "._fillet" pause pause)
      (setvar "filletrad" old_filletrad)
      (setvar "cmdecho" old_cmdecho)
      (princ)
    )[/code]

  • Alternative:
    Customize menu, add a menu item with your f;r;0; command.
    Create a keyboard shortcut (to Ctrl+3 (or any other unused shortcut)) using the same command.
  • I apologize for introducing some confusion here. I repeatedly used the terms "shortcut" and "keyboard shortcut" when I meant "command alias." I think an alias is what Sascha was looking for, and an alias is what I was trying to say that I've never been able to assign to a script. Is there a way to do that?

    I enter all commands from the keyboard, using one- or two-letter aliases, but I avoid Ctrl, Shift, and Alt key combinations, which of course is what the term "shortcut" actually refers to.
  • Attach my take on filleting commands
    [code]; MULTIPLE FILLET WITH ZERO RADII
    (defun C:FilletMultiple0 ( / *error*)
        ; define local error handler
        (defun *error* (error_msg)
            (if error_msg (princ (STRCAT "\n" error_msg))) ; Print error message if given
          (acet-sysvar-restore); reset environment variables
         (prin1); exit quietly
        ) ; end *error*
        ; Save the current FILLETRAD state and set to zero
      (acet-sysvar-set '("FILLETRAD" 0.0)) ; Save environment variables
      (command "._FILLET" "_MULTIPLE")
      ; While the command is still active pause to allow user input
      (while (wcmatch (getvar 'CMDNAMES) "FILLET")(command pause))
    (acet-sysvar-restore); reset environment variables
    )

    ; MULTIPLE FILLET WITH DEFAULT RADII
    (defun C:FilletMultiple ( )
      (acet-sysvar-set '("CMDECHO" 0)) ; Save environment variables
       (command "._FILLET" "_MULTIPLE")
    (acet-sysvar-restore); reset environment variables
    )

    ; SETFILLET RADIUS
    (defun C:FilletRadius ( )
      (acet-sysvar-set '("CMDECHO" 0)) ; Save environment variables
      (command "._FILLET" "_RADIUS")
     (acet-sysvar-restore); reset environment variables
    )[/code]

    Also you can assign command alias to LISP functions, which avoids having to editing the LISP file. It also allows you to give a more meaningful name to the LISP function, rather than a cryptic shortcut. The option to do this isn't immediately obvious if you edit command alias via the CUI, but when adding instead of selecting a built-in command type in the LISP function name instead.

    Regards, Jason Bourhill CAD Concepts 

    CCL-Fillet.lsp

    imageLISP-CommandAlias.png
  • Hello.

    Thanks for the help.
    Anthony made it work!
    If you type in: (command "_fillet" "r" "0" "_fillet") insteed of (command "_fillet" "r" "0") as alias for e.g. "n", it works!

    Sascha
  • That's an interesting discovery Sascha. It's not possible to do that in the other .dwg CAD app :-).

    Regards, Jason Bourhill CAD Concepts 
  • Hey Jason,

    yes, but it should be that easy to customize your Bricscad or other CAD App.
    This is what everybody can easily handle with a tiny bit of timeinvest.
    Who can handle these Lisp-functions? Not the "normal" CAD-User like me....

    Greetings.
This discussion has been closed.