trouble creating macro

I'm having trouble navigating the cui file to do this:
I have a macro; ^C^C_move;0,0,0;0,0,200;z ob p;bkg_groupungroup p;_stopscript;

My process was: File > create partial cui> create toolbox> create tool in the toolbox> append tool and insert macro in the command field, then give it a name in the name field.

Click ok, then try the command name in the command line and.. "unable to recognize command.."

What am I doing wrong - this process seems crazy complicated or am I stupid? ;-)


  • To be clear, it's creating a new command and having it be recognized by BC that's giving me trouble.

    Any thoughts are appreciated.

  • You've create a menu macro, not a command. Macro's can be accessed from a menu only.

    To create a command you would use some LISP. E.g

    (Defun C:MUG ()



  • Thanks for getting back. What I want in the end is a macro that is activated by a keyboard shortcut. I will select a group of entities, then key the macro which moves the group up 200, ungroups it, and zooms to these items. Sorry for the terminology confusion, I think I've been running in circles here. Could you briefly describe the steps to go about this? It's a task I do 100 times a day so I have to find a way to automate it.

  • Ok some hints in CAD there is noun/verb verb/noun ie select 1st or when asked, in a program say lisp its generally easier to ask select objects and make a selection set then do something with those objects like move. Notice I did not use the word "GROUP" as that is a function within CAD.

    Now 1st question is move always 200 up or maybe left right up or down. Hope you understand where I am going.

    How much do you know about lisp ? It is a good task to start learning. So here is a start.

    (defun c:up200 ( / )

    (setq ss (ssget)) ; makes a selection set of objects

    (command "MOVE" ss "" "0,0,0" (0,200,0) )

    ; next step



    Next step is make it way smarter say function 200U for up 200D for down etc so it can move in four directions by choice.

    Ok zoom to all selected objects and I learnt something today Zoom OB !ss needs to be translated into lisp using (vla-sendcommand (vla-get-activedocument (vlax-get-acad-object)) "zoom ob !ss ")

    Now if we wanted it real smart I would type U200 then it would ask to select objects and move up 200, but I want L150 again that is what I would type. I have a program that looks at what you type and pulls it apart so it looks at the U D L R then reads the value. It does not exist but it does for circles fillets and offsets so I can have 26 different ideas A-Z. C123 O45 F12.

    Anyway have a go at making a lisp for 200U if you get stuck just ask again here. Ps save in say a file called custom.lsp you may have more functions to add that you use all the time, Then Appload add to Startup, then its ready in every dwg no need to load it.

  • Thanks for getting back. I will give this a go - I like the idea of loading only one lisp with multiple functions. Much more portable for upgrades, and easier to keep track of things! Much appreciated.

  • Anthony Apostolaros
    edited June 5

    Keyboard shortcuts are defined in the Keyboard tab of the Customize dialog box:

    • Right-click on a shortcut in the left pane, select "Insert shortcut."
    • Select the "Create new tool" radio button.
    • Type or paste your macro in the "Command" field.
    • Fill in other fields, optionally.
    • Click "OK."
    • In the Key field in the bottom pane, type the function key or combination key you want to use to execute the macro.
    • Click "OK."

  • Thank you - I'll try that.

    edited June 7

    I found the CUI so hard to play with look at making your own custom Menu's these are created by you using just notepad, you can have pop and toolbar menu's, you need to use the CUI if you want ribbon options.

    For anyone did you know can look inside a CUI and CUIX. But be careful if you have a go at editing them.

  • It seems like you're shifting objects to a clear drawing area to edit them, then move them back?

    If this is the case, have you considered using ISOLATEOBJECTS & UNISOLATEOBJECTS instead?

    This avoids moving anything on your drawing, which could lead to errors.


    Jason Bourhill

    BricsCAD V24 Ultimate

  • Jason, I do use those constantly, but in this case was moving so I have access to other items in the drawing if needed. But I was not aware of potential errors. What errors would those be and how would moving cause them? I do get some showing up in audit occasionally and wondered why.

    ALANH, that looks like a great way to go thanks

  • I just remembered the real reason I use move instead of isolate / unisolate;

    Because if I isolate a group, ungroup and edit it, there is usually a point where I need to hide or isolate one off the parts. Then if I unisolate those parts when I'm done, the whole drawing pops back into view, and I can't then re group my cabinet without picking the parts one by one.

    I am concerned about errors using move with the macro though, as Jason suggests, so would like to explore other options if there are any. I always wondered if there could be multiple levels of isolate / hide, so you could hide objects 3 different times, then bring them all back at once or one at a time. Might get confusing, but worth exploring the idea I think. Maybe in a right click menu? Thinking out loud here.

  • Anthony Apostolaros
    edited June 12

    Would it help to be able to save a selection set and then re-select it later? Without having to pick the entities one-by-one?

    If so, that's easy to do, by typing Lisp functions on the command line, or by defining lisp-based custom commands. You wouldn't have to create a group or a block, just a named selection set.

    Select all the entities you want in the selection set, and enter this on the command line:
    (setq xlw (ssget))
    Then whenever you want that selection set selected and highlighted again, enter:
    (sssetfirst nil xlw)

    If you want to make each of those lisp functions a custom command (so that instead of typing all that you can just enter X1 and X2), put these in your "on_doc_load.lsp" file:
    (defun c:X1 () (setq xlw (ssget)))
    (defun c:X2 () (sssetfirst nil xlw))

    Or put each of those lisp functions in a Menu Macro or a Keyboard Shortcut.

  • Would the selection set stay with the drawing or be erased when the drawing is closed?

  • Anthony Apostolaros
    edited June 14

    The variable that stores the list of entities would be forgotten when the .dwg file is closed. If you want to use the X2 command again after closing and re-opening the file, you'd have to save the list of entities in some other way.

    For example, you could use the X2 command and then the Block command to replace all the entities with a block insertion. Then when you re-open the file you could select that block insertion and explode it, and put all the exploded entities in a new selection set with the same name. Then the X2 command would keep working as if you'd never closed the file.

    This custom command should do that. It also purges the temporary block definition, so you can use the same block name again the next time you close the file:

    (defun c:X3 ()
    (setq ss1 (ssget '((0 . "INSERT"))))
    (setq Bname1 (cdr (assoc 2 (entget (ssname ss1 0)))))
    (setq xlw (acet-explode ss1))
    (command "Purge" "b" bname1 "y" "y")
    (sssetfirst nil xlw)