Add command to Context Menu

How can command be added to context menu, when it's a custom one.
I have already loaded a LISP file via APPLOAD.
Not sure if the LISP routine works in BricsCAD but will deal with that next (it works in AutoCAD).

I figured out how to add standard commands to context menu:
Type CUSTOMIZE or CUI. In Menu tab, go to Context menus. Right click, Insert item, select Create new tool for example, fill in details.

Comments

  • Anthony Apostolaros
    edited May 8
    Yes, that's how you add a custom command to a context menu. Are you clear on the different types of context menus, e.g. Command, Default, and Edit?
    If you post a lisp function here, people (not me) can tell you what needs to be changed, if anything.
  • Thanks Anthony, it's Default or Edit, but this is a custom command, not one already in there, so how do I create the command to shown in context menu.
    The Lisp is create a block in place:

    (defun c:Create_block_in_place (/ bkn eee i ndx nm ssst st)
        (if (and (setq ssst (ssget)) (setq st (getpoint "\nPick Base Point: ")))
        (progn (setq ndx 0)
            (setq time (rtos (getvar "CDATE") 2 6)) ; Format YYYYMMDD.HHMMSS
            (setq year (substr time 3 2)) ; Two digits instead of four
            (setq month (substr time 5 2))
            (setq day (substr time 7 2))
            (setq hour (substr time 10 2)) ; Increment of 3 from day to account for "." character
            (setq minutes (substr time 12 2))
            (setq seconds (substr time 14 2))
            (while (tblobjname "block" (setq nm (strcat "Block-" year month day hour minutes seconds))))
            (entmake (list '(0 . "BLOCK")
                '(100 . "AcDbEntity")
                '(67 . 0)
                '(8 . "0")
                '(100 . "AcDbBlockReference")
                (cons 2 nm)
                (cons 10 st)
                '(70 . 0)
                       )
            )
            (repeat (sslength ssst)
                (entmake (cdr (entget (ssname ssst ndx))))
                (entdel (ssname ssst ndx))
                (setq ndx (+ 1 ndx))
            )
            (entmake '((0 . "ENDBLK") (100 . "AcDbBlockEnd") (8 . "0")))
            (entmake (list (cons 0 "INSERT")
                (cons 2 nm)
                (cons 6 (getvar "CELTYPE"))
                (cons 8 (getvar "CLAYER"))
                (cons 66 0)
                (cons 10 st)
                (cons 41 1)
                (cons 42 1)
                (cons 43 1)
                (cons 50 0)
                (cons 71 0)
                (cons 44 0)
                (cons 45 0)
                       )
            )
        )
        )
        (princ)
    )
  • Anthony Apostolaros
    edited May 9
    That custom command works for me. I added it to my Default and Edit context menus, and that works too.

  • OK thanks Anthony, at least I know how to add now.

    But the actual LISP is not working. It is running because it asks to pick a base point, but then nothing.
  • It works perfectly for me. If anything is selected, it just prompts for a base point. If nothing is selected, it prompts for a selection set and then for a base point. In either case, it turns the selection set into a block whose name includes the precise time that the base point was picked.
    There's no visible change when the block is created, unless the selection set includes a Byblock color. But when I try to select anything in the selection set, the block is selected instead.
  • Thanks Anthony, it may be a setting that's preventing this then