Create a custom HKA

I would like to create a wrapper for the offset command because I think the "Offseterase" variable should be controlled on the fly. How do I create a custom HKA?

Comments

  • I don't know what you mean. Maybe this?
    (defun c:on () (command "offset" "e" "n") ) (defun c:oy () (command "offset" "e" "y") )
  • I mean recreating the Ctrl key effect. Hot key assist (HKA) wherein mid command you can toggle something using the Ctrl key
  • Anthony Apostolaros
    edited August 2022
    Sorry, but I've never heard of Hot Key Assist, or the Ctrl key effect, or using the Ctrl key to toggle something. I didn't find anything by googling those terms.

    You said "recreating" the Ctrl key effect. Were you previously able to toggle the OffsetErase variable by pressing the Ctrl key? And were you able to do that transparently during the Offset command?

    If so, I agree that it sounds useful. It would be like the ability to toggle OrthoMode during any command by pressing and holding the Shift key, or by pressing and releasing F8. And toggling PickAdd by pressing and holding the Shift key during selection. I can think of other things I'd like to be able to toggle in that way, but I don't know of any other examples of things that actually do work that way.

    I think my macro utility, Macro Express, would allow me to do it by pressing a Ctrl-key combination or Function key that then executes a lisp function. Maybe Bricscad's built-in keyboard macro utility would allow it too.

    But I don't think a lisp function could use just the Ctrl key to toggle something. I don't know of any way to pass the pressing and release of the Ctrl key to a lisp function.

    Macro Express can pass the pressing and release of any key to any program, but it would do that every time I use the Ctrl key in Bricscad. The lisp function it executes would have to return nil unless the Offset command is active. I don't know of any way to get the name of the currently active command. Hmmm.... but lisp can test for whether a command is active. Maybe that would be enough. But not if I wanted the Ctrl key to toggle something else during some other command.

    The code I posted above creates two custom commands. Both work just like the built-in Offset command, except that one always deletes the source object and the other always keeps it. With a little more work, they could each restore the OffsetErase variable on termination.
  • Look into transparent commands use a single quote, how do I explain, you can call a lisp defun in the middle of a command, eg LINE pickpoint 'qtr this would have effect of finding the 1/4 point of say 2 points then continue the line command. The (defun c:qtr is code for finding 1/4 point.
  • Anthony Apostolaros
    edited August 2022
    Yes, as Alan said, you could create a custom command that toggles the OffsetErase variable, and execute it transparently during the Offset command by preceding it with a single-quote. If you alias it to a single character whose key is near the single-quote key, such as the [ character, you would just have to type '[<enter> at any time during the Offset command to toggle OffsetErase on or off. That's not as convenient as just holding down the Ctrl key whenever you want source objects deleted, but maybe it's better than nothing.

    With Macro Express, and maybe with the built-in macro utility, I could instead assign 'ToggleOffsetErase to a function key. Then I would just have to hit that function key to execute the toggle. But I have 24 function keys. Most users probably don't have a function key to spare.

    (defun c:ToggleOffsetErase () (if (= (getvar "OffsetErase") 0) (setvar "OffsetErase" 1) (setvar "OffsetErase" 0) ))