Creating custom buttons to tool palette

Creating custom buttons to tool palette

MrMuscl3
Advocate Advocate
3,629 Views
12 Replies
Message 1 of 13

Creating custom buttons to tool palette

MrMuscl3
Advocate
Advocate

I have become frustrated with my tryouts to create some buttons for making my life easier. I've tried to create these to my tool palette. Manage -> User Interface -> Customize -> Command List -> Run Script -> Drag n drop to Tool Palette -> Right click the script -> Properties -> Command string

I've been trying to create following buttons and only one worked Smiley Frustrated

Close drawing without saving (close no, did not work)
Close drawing and save (qsave close)
Close all drawings without saving
Close all drawings and save

How to create these buttons to tool palette with using Run Script Command String?

I'm little bit lost here because the "input style" varies very much depending on what I'm trying to do. Command line usage is clear to me and recently I created a thread here for running long command line command strings in a .scr file which was used with drag n drop method. I don't know anything about VBA code so I have to just skip every google match with that kind of solutions. I also use AutoCAD LT and if I have understood things right, LT has no LISP support and all LISPS are written in VBA (please correct me if im wrong).

 

Does the input style of these custom created buttons differ from command strings in .scr file?

AutoCAD 2025
0 Likes
3,630 Views
12 Replies
Replies (12)
Message 2 of 13

steven-g
Mentor
Mentor

Where do you want the commands to run from, that's what we need to find out first, you have the choice of menu, ribbon, toolbar, or toolpalette.

With the exception of the toolpalette you need to be creating the commands from within the CUI, the toolpalette is slightly different and will let you edit and create new commands from the toolpalette itself.

 

Following along with your description, it looks like you have gotten as far as getting something into a toolpalette - correct??

 

From there things need to change, as you won't be using a script (unless you really really want too)

 

Which place for the buttons would best suit your work method, when you know that we can try and get you started on the learning path for macro's and possibly even Diesel if you're feeling adventurous. And indeed there is no Lisp or VBA in LT.

Message 3 of 13

pendean
Community Legend
Community Legend

CUI command is where you add or remove commands to use in Ribbon panels, Toolbars (aka buttons) and drop-down Menu files.

Look at the COMMANDS LIST section,that is where you add them first before you drag them to where you want to use them. Here are some tutorials to get you started, more content on the web so help yourself
http://www.cad-notes.com/exploring-autocad-cui-creating-a-command-part-2/
and
http://www.cadalyst.com/cad/autocad/create-your-own-autocad-commands-circles-and-lines-autocad-tutor...

plus

http://www.ellenfinkelstein.com/acadblog/tutorial-automate-tasks-with-a-script-file/

Message 4 of 13

Emmsleys
Alumni
Alumni

Following up on your thread, were you able to find a solution or a workaround? Did any of the posts in the thread help with the issue?

 

Please use the Accept as Solution for those post’s that helped. It may benefit other users who might have a similar question or issue.

 

Or post with any new updates if you need continued help on your thread. 

 

Thanks for your time.         



Sarah Emmsley
Technical Support Specialist

0 Likes
Message 5 of 13

MrMuscl3
Advocate
Advocate

steven-g: I would like to create the buttons to toolpalette. I have managed to create "buttons" to tool palette. I think that with my limited abilities it is better to proceed with macros than diesel.

 

Through the links that Dean posted I have understoond what the following parts in macros stand for:

 

^C^C = ESC ESC

; = Enter

\ = Pause the macro for user input

 

If there are any other special characters that I should know about, please let me know.

 

The buttons Im trying to create are

 

Close drawing without saving

Close drawing and save (^C^C_qsave;close)

Close all drawings without saving

Close all drawings and save

 

First problem lies with the confirmation box that appears when I try to close drawing when it has not been saved before closing. How would the macro part look when AutoCAD prompts you with window and you want to reply with word to it?

 

Second problem is how to quicksave all. I think that autocad does not have command "quicksave all". I only managed to find "closeall". Any ideas for this one?

 

One of the links that Dean posted contains simple quide for macro "input style". I have read it and also looked few things from google. One thing is this unclear to me. People seem to start their macros with different ways. Here are some examples:

 

^C^Ccircle

^C^C-circle

^C^C_circle

 

What is the difference with these? Can you allways write the command right after ^C^C and what is the function of - or _?

AutoCAD 2025
Message 6 of 13

steven-g
Mentor
Mentor

Here is a list of special control characters used in macro's https://knowledge.autodesk.com/support/autocad-lt/learn-explore/caas/CloudHelp/cloudhelp/2016/ENU/Au...

There is one missing from the list and that is "-" this uses a version of the command that uses keyboard entry in place of a dialogue box.

A macro cannot work when a command opens a dialogue box, so for example a save command won't let you pause the command and fill in the new name, and then continue to the next command, any dialogue box will open but then stop the macro at that point, the variable filedia=0 will allow certain dialogue boxes to run with keyboard entry.

 

If you can't find a method to run a command from the keyboard then you can't put it in a macro, for example "qselect" 

Message 7 of 13

MrMuscl3
Advocate
Advocate

Well, it seems that these operations cant be done with macro. So that leaves me following options:

 

- Action recorder (not available for LT)

- LISP (not available for LT)

- Diesel ( bit hard for newbie like me? )

- Script

 

Could these be written in script? Also, can I place written script .scr file to toolpalette?

AutoCAD 2025
0 Likes
Message 8 of 13

steven-g
Mentor
Mentor

The same rules apply to a script, there is no way in LT to bypass or fill in details in a dialogue, once the dialogue opens it stops any script or macro from continuing, plus a script cannot pause for user input like a macro, and diesel won't help with dialogues either.

A script can be placed in a toolpalette by using a macro that calls the script. These are some of the limitation of LT. Though quite often it is possible to come up with workarounds, it can be quite frustrating to figure out how, and sometimes you just have to accept that it will take a few extra steps.

Message 9 of 13

steven-g
Mentor
Mentor

Here's a macro to close without saving,

^C^C^Csaveas;2007;temp;y;close;

 

it tricks Autocad into closing the drawing by renaming it as temp.dwg and then closing temp.dwg which has just been created, this does create a file temp.dwg somewhere on your computer but it will be overwritten everytime you use the macro (it may fail the very first time you run it untill the temp.dwg has been created).

As far as running a macro on multiple files open files is concerned, thats another drawback in LT a macro/script will only work on the current active drawing, and the closeall command actually opens a dialogue which will require further input for each drawing.

Message 10 of 13

MrMuscl3
Advocate
Advocate

Could you help me with creating macro for following steps:

 

1. Choose first layout, Zoom Extents

2. .....

3. Choose last layout, Zoom Extents

4. Choose MS, Zoom Extents

5. Quick Save, Close Drawing

 

I wonder if moving from first layout to last layout without knowing the exact number of layouts or names of layouts will be problem with this?

 

I think this would be great macro for the next user whoever it will be.

AutoCAD 2025
0 Likes
Message 11 of 13

steven-g
Mentor
Mentor

I wish I could, I have never found a way to navigate layouts (other than by known name), you can't tab to the next layout in a macro or anything like that, but I do hope that someone else may know of a trick for that.

0 Likes
Message 12 of 13

pendean
Community Legend
Community Legend
Do all of your layouts have the same exact names and are the same exact quantities?

As in you have to pre-identify "first layout" and "last layout" and any others you want to touch with a macro first, and these two (or more) layout names must remain consistent and be present in all of your DWG files.

Or are you not that organized yet and leave things up to chance or named by others randomly? let us know.
0 Likes
Message 13 of 13

Kent1Cooper
Consultant
Consultant

@MrMuscl3 wrote:

.... People seem to start their macros with different ways. Here are some examples:

 

^C^Ccircle

^C^C-circle

^C^C_circle

 

What is the difference with these? Can you allways write the command right after ^C^C and what is the function of - or _?


To expand on that question....

 

Most macros start with ^C^C to get out of any command that may be active when you run them [typically doubled because some commands require two cancels to fully get out of them], but they don't need to -- in fact, you can make macros that intentionally don't start that way, such as for transparent commands like 'ZOOM, which you don't want cancelling the command you're in, since you sometimes want to be able to do it within another command [although for that one, most people just use the mouse wheel].

 

The - hyphen prefix is to use the command-line version of a command that normally operates from a dialog box, such as -LAYER.  [It would be meaningless with the CIRCLE command.]

 

The _ underscore is to make the English command names work in different-language versions of AutoCAD.  If you use the English version, you never need that, but lots of things posted on these Forums use it, because people from all over the world find code they can use here.

 

The other thing you should know about is the . decimal-point prefix.  That causes it to use the native AutoCAD version of a command, in case it may have been Undefined and a new definition written.  For example, some overlay programs have their own somewhat different definitions for some commands for enhanced functionality, with the native versions Undefined, but you can get the native version by starting it with a period/decimal point.

 

You can use them together.  They don't work in every possible order, though more than one possible order will work; I remember one of the workable sequences by order of vertical position, low to high:

 

_.-LAYER

 

works.

Kent Cooper, AIA