Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Add quick access button "externally"

12 REPLIES 12
Reply
Message 1 of 13
MRCH94D9W
764 Views, 12 Replies

Add quick access button "externally"

MRCH94D9W
Enthusiast
Enthusiast

I have added a quick access button to autocad to run the following line:

^C^C_shell "C:/Users/myuser/test.bat";

 

This line is needed on multiple computers, and I would like to create a "setup" file so people can just double click on it and the button will be installed in their autodesk installation. Is this possible?

0 Likes

Add quick access button "externally"

I have added a quick access button to autocad to run the following line:

^C^C_shell "C:/Users/myuser/test.bat";

 

This line is needed on multiple computers, and I would like to create a "setup" file so people can just double click on it and the button will be installed in their autodesk installation. Is this possible?

12 REPLIES 12
Message 2 of 13
paullimapa
in reply to: MRCH94D9W

paullimapa
Mentor
Mentor

I see this .net method on doing this 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos

I see this .net method on doing this 


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
Message 3 of 13
MRCH94D9W
in reply to: paullimapa

MRCH94D9W
Enthusiast
Enthusiast

It seems overly complex to need +200 lines of #C code to add a simple button autocad?

I believe I should be able to add a button just by editing the CUIX files?


This is as far as I've come. I've created a custom button as shown here:
 

MRCH94D9W_1-1715929408327.png

 

looking into the acad.cuix I'm able to find that item here:

 

<?xml version="1.0"?>
<!--
Warning! Do not edit the contents of this file.
If you attempt to edit this file using an XML editor, you could lose
customization and migration functionality. If you need to change
information in the customization file, use the Customize User Interface
dialog in the product.
To access the Customize User Interface dialog, click the Tools menu,
Customization panel, User Interface button, or enter CUI on the command line.
-->
<QuickAccessToolbarRoot xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <QuickAccessToolbar UID="QAT_TOOLBAR1">
    <ModifiedRev MajorVersion="24" MinorVersion="3" UserVersion="1" />
    <Name xlate="true" UID="XLS_QAT_Name">Quick Access Toolbar 1</Name>
    <QuickAccessToolbarStandardItem UID="ID_QAT_New" Id="AcQATNew">
      <ModifiedRev MajorVersion="18" MinorVersion="0" UserVersion="0" />
    </QuickAccessToolbarStandardItem>
    <QuickAccessToolbarStandardItem UID="ID_QAT_Open" Id="AcQATOpen">
      <ModifiedRev MajorVersion="18" MinorVersion="0" UserVersion="0" />
    </QuickAccessToolbarStandardItem>
    <QuickAccessToolbarStandardItem UID="ID_QAT_Save" Id="AcQATSave">
      <ModifiedRev MajorVersion="18" MinorVersion="0" UserVersion="0" />
    </QuickAccessToolbarStandardItem>
    <QuickAccessToolbarStandardItem UID="ID_QAT_SaveAs" Id="AcQATSaveAs">
      <ModifiedRev MajorVersion="18" MinorVersion="1" UserVersion="0" />
    </QuickAccessToolbarStandardItem>
    <QuickAccessToolbarStandardItem UID="ID_QAT_OpenFromWebMob" Id="AcQATOpenFromWebMob">
      <ModifiedRev MajorVersion="23" MinorVersion="0" UserVersion="0" />
    </QuickAccessToolbarStandardItem>
    <QuickAccessToolbarStandardItem UID="ID_QAT_SaveToWebMob" Id="AcQATSaveToWebMob">
      <ModifiedRev MajorVersion="23" MinorVersion="0" UserVersion="0" />
    </QuickAccessToolbarStandardItem>
    <QuickAccessToolbarStandardItem UID="ID_QAT_Plot" Id="AcQATPlot">
      <ModifiedRev MajorVersion="18" MinorVersion="0" UserVersion="0" />
    </QuickAccessToolbarStandardItem>
    <QuickAccessToolbarStandardItem UID="ID_QAT_Undo" Id="AcQATUndo">
      <ModifiedRev MajorVersion="18" MinorVersion="0" UserVersion="0" />
    </QuickAccessToolbarStandardItem>
    <QuickAccessToolbarStandardItem UID="ID_QAT_Redo" Id="AcQATRedo">
      <ModifiedRev MajorVersion="18" MinorVersion="0" UserVersion="0" />
    </QuickAccessToolbarStandardItem>
    <RibbonCommandButton UID="ID_RBN__243_602B8" Id="AcRibbonCommandButton" Text="mycommand" ButtonStyle="SmallWithoutText" MenuMacroID="MMU_243_C51F6">
      <ModifiedRev MajorVersion="24" MinorVersion="3" UserVersion="1" />
    </RibbonCommandButton>
  </QuickAccessToolbar>
</QuickAccessToolbarRoot>

 

 

This only places the "dead button" though. I need to find where the Macro element is located in order to create something that can add it automatically.

0 Likes

It seems overly complex to need +200 lines of #C code to add a simple button autocad?

I believe I should be able to add a button just by editing the CUIX files?


This is as far as I've come. I've created a custom button as shown here:
 

MRCH94D9W_1-1715929408327.png

 

looking into the acad.cuix I'm able to find that item here:

 

<?xml version="1.0"?>
<!--
Warning! Do not edit the contents of this file.
If you attempt to edit this file using an XML editor, you could lose
customization and migration functionality. If you need to change
information in the customization file, use the Customize User Interface
dialog in the product.
To access the Customize User Interface dialog, click the Tools menu,
Customization panel, User Interface button, or enter CUI on the command line.
-->
<QuickAccessToolbarRoot xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <QuickAccessToolbar UID="QAT_TOOLBAR1">
    <ModifiedRev MajorVersion="24" MinorVersion="3" UserVersion="1" />
    <Name xlate="true" UID="XLS_QAT_Name">Quick Access Toolbar 1</Name>
    <QuickAccessToolbarStandardItem UID="ID_QAT_New" Id="AcQATNew">
      <ModifiedRev MajorVersion="18" MinorVersion="0" UserVersion="0" />
    </QuickAccessToolbarStandardItem>
    <QuickAccessToolbarStandardItem UID="ID_QAT_Open" Id="AcQATOpen">
      <ModifiedRev MajorVersion="18" MinorVersion="0" UserVersion="0" />
    </QuickAccessToolbarStandardItem>
    <QuickAccessToolbarStandardItem UID="ID_QAT_Save" Id="AcQATSave">
      <ModifiedRev MajorVersion="18" MinorVersion="0" UserVersion="0" />
    </QuickAccessToolbarStandardItem>
    <QuickAccessToolbarStandardItem UID="ID_QAT_SaveAs" Id="AcQATSaveAs">
      <ModifiedRev MajorVersion="18" MinorVersion="1" UserVersion="0" />
    </QuickAccessToolbarStandardItem>
    <QuickAccessToolbarStandardItem UID="ID_QAT_OpenFromWebMob" Id="AcQATOpenFromWebMob">
      <ModifiedRev MajorVersion="23" MinorVersion="0" UserVersion="0" />
    </QuickAccessToolbarStandardItem>
    <QuickAccessToolbarStandardItem UID="ID_QAT_SaveToWebMob" Id="AcQATSaveToWebMob">
      <ModifiedRev MajorVersion="23" MinorVersion="0" UserVersion="0" />
    </QuickAccessToolbarStandardItem>
    <QuickAccessToolbarStandardItem UID="ID_QAT_Plot" Id="AcQATPlot">
      <ModifiedRev MajorVersion="18" MinorVersion="0" UserVersion="0" />
    </QuickAccessToolbarStandardItem>
    <QuickAccessToolbarStandardItem UID="ID_QAT_Undo" Id="AcQATUndo">
      <ModifiedRev MajorVersion="18" MinorVersion="0" UserVersion="0" />
    </QuickAccessToolbarStandardItem>
    <QuickAccessToolbarStandardItem UID="ID_QAT_Redo" Id="AcQATRedo">
      <ModifiedRev MajorVersion="18" MinorVersion="0" UserVersion="0" />
    </QuickAccessToolbarStandardItem>
    <RibbonCommandButton UID="ID_RBN__243_602B8" Id="AcRibbonCommandButton" Text="mycommand" ButtonStyle="SmallWithoutText" MenuMacroID="MMU_243_C51F6">
      <ModifiedRev MajorVersion="24" MinorVersion="3" UserVersion="1" />
    </RibbonCommandButton>
  </QuickAccessToolbar>
</QuickAccessToolbarRoot>

 

 

This only places the "dead button" though. I need to find where the Macro element is located in order to create something that can add it automatically.

Message 4 of 13
MRCH94D9W
in reply to: MRCH94D9W

MRCH94D9W
Enthusiast
Enthusiast

bump

0 Likes

bump

Message 5 of 13
cadffm
in reply to: MRCH94D9W

cadffm
Consultant
Consultant

Hi,

if you want to go this way... please let me know, how it ended up.

 

Look at the MenuGroup.cui ! (multiple places/parts inside)

Sebastian

0 Likes

Hi,

if you want to go this way... please let me know, how it ended up.

 

Look at the MenuGroup.cui ! (multiple places/parts inside)

Sebastian

Message 6 of 13
MRCH94D9W
in reply to: cadffm

MRCH94D9W
Enthusiast
Enthusiast

I don't necessarily want to go that way. If there's an easier option I'm all ears!

 

I just wouldn't have imagined that creating a script that will add a button to the menu would be so difficult that one would have to write 200+ lines of C code or modifying nested CUI files.

 

I'm very much interested in the simplest possible solution.

0 Likes

I don't necessarily want to go that way. If there's an easier option I'm all ears!

 

I just wouldn't have imagined that creating a script that will add a button to the menu would be so difficult that one would have to write 200+ lines of C code or modifying nested CUI files.

 

I'm very much interested in the simplest possible solution.

Message 7 of 13
cadffm
in reply to: MRCH94D9W

cadffm
Consultant
Consultant

Hi,

 

200 or 2000 doesn't matter if already present - the best way you have.

 

The way you are talking is much more crazy in my ears 😆

Editing nested and compressed files with unknown content, because you have to know

all users on each workstation

*

each profile (with unknown content)

*
each used main .cuix (add  the button)

*

each workspace  (add the button)

 

 

 

 

 

Sebastian

0 Likes

Hi,

 

200 or 2000 doesn't matter if already present - the best way you have.

 

The way you are talking is much more crazy in my ears 😆

Editing nested and compressed files with unknown content, because you have to know

all users on each workstation

*

each profile (with unknown content)

*
each used main .cuix (add  the button)

*

each workspace  (add the button)

 

 

 

 

 

Sebastian

Message 8 of 13
pendean
in reply to: MRCH94D9W

pendean
Community Legend
Community Legend

@MRCH94D9W wrote:

.... and the button will be installed in their autodesk installation....

...will add a button to the menu ... or modifying nested CUI files.

...I'm very much interested in the simplest possible solution....


Looks like your company is ready to adopt ENTERPRISE CUI, how Autodesk wants you do do it.

Enjoy the switch.

 


@MRCH94D9W wrote:

.... and the button will be installed in their autodesk installation....

...will add a button to the menu ... or modifying nested CUI files.

...I'm very much interested in the simplest possible solution....


Looks like your company is ready to adopt ENTERPRISE CUI, how Autodesk wants you do do it.

Enjoy the switch.

 

Message 9 of 13
TheCADnoob
in reply to: MRCH94D9W

TheCADnoob
Mentor
Mentor

What is the button actually installing? I assume installing the button is a way to allow the user to then further install something. 

 

could you bypass the need for the use to setup the install by running a lisp at startup that puts what ever setting you need in place?

 

https://help.autodesk.com/view/OARX/2022/ENU/?guid=GUID-FDB4038D-1620-4A56-8824-D37729D42520

CADnoob

EESignature

0 Likes

What is the button actually installing? I assume installing the button is a way to allow the user to then further install something. 

 

could you bypass the need for the use to setup the install by running a lisp at startup that puts what ever setting you need in place?

 

https://help.autodesk.com/view/OARX/2022/ENU/?guid=GUID-FDB4038D-1620-4A56-8824-D37729D42520

CADnoob

EESignature

Message 10 of 13
MRCH94D9W
in reply to: TheCADnoob

MRCH94D9W
Enthusiast
Enthusiast

That could be a solution.

 

The button doesn't install anything, it simply runs a python script which exports data from a database file which is in turn generated through Sofistiks Autocad plugin (Sofiplus).

 

I've found the following autolisp script which as far as I can tell, should add a button when run. But when I run it, it simply states "AddButton.lsp successfully loaded", but no button appears.

 

(defun c:AddBasicButton ()
(vl-load-com)
(setq acadObj (vlax-get-acad-object))
(setq doc (vla-get-ActiveDocument acadObj))

;; Macro for the command
(setq cmdMacro "^C^C_shell "C:/Users/myuser/test.bat";")

;; Get the Quick Access Toolbar
(setq menus (vla-get-MenuGroups acadObj))
(setq customToolbar (vla-Item (vla-get-Toolbars (vla-Item menus 0)) 0))

;; Add the button to the Quick Access Toolbar
(setq button (vla-AddToolbarButton customToolbar "RunMacroButton" "Run Macro" cmdMacro))

;; Ensure the toolbar is visible (typically QAT is always visible)
(vlax-put-property customToolbar 'Visible :vlax-true)

;; Debug message
(princ "\nBasic button added to Quick Access Toolbar.")
(princ)
)

(c:AddBasicButton)

 

 

0 Likes

That could be a solution.

 

The button doesn't install anything, it simply runs a python script which exports data from a database file which is in turn generated through Sofistiks Autocad plugin (Sofiplus).

 

I've found the following autolisp script which as far as I can tell, should add a button when run. But when I run it, it simply states "AddButton.lsp successfully loaded", but no button appears.

 

(defun c:AddBasicButton ()
(vl-load-com)
(setq acadObj (vlax-get-acad-object))
(setq doc (vla-get-ActiveDocument acadObj))

;; Macro for the command
(setq cmdMacro "^C^C_shell "C:/Users/myuser/test.bat";")

;; Get the Quick Access Toolbar
(setq menus (vla-get-MenuGroups acadObj))
(setq customToolbar (vla-Item (vla-get-Toolbars (vla-Item menus 0)) 0))

;; Add the button to the Quick Access Toolbar
(setq button (vla-AddToolbarButton customToolbar "RunMacroButton" "Run Macro" cmdMacro))

;; Ensure the toolbar is visible (typically QAT is always visible)
(vlax-put-property customToolbar 'Visible :vlax-true)

;; Debug message
(princ "\nBasic button added to Quick Access Toolbar.")
(princ)
)

(c:AddBasicButton)

 

 

Message 11 of 13
TheCADnoob
in reply to: MRCH94D9W

TheCADnoob
Mentor
Mentor

Im not sure the lisp code does what you are trying to do. Where did you get it?

 

I had to add a parameter to vla-AddToolbarButton to get it to work and I also had to move the visibility part prior to the add button part.

 

After that it was loading the button to the mesh toolbar

 

TheCADnoob_0-1722349799553.png

 

 

Here is a link to someone adding a button to QAT but they used .net (edit: its the same link @paullimapa posted)

https://www.keanw.com/2010/04/adding-to-autocads-application-menu-and-quick-access-toolbar-using-net...

CADnoob

EESignature

0 Likes

Im not sure the lisp code does what you are trying to do. Where did you get it?

 

I had to add a parameter to vla-AddToolbarButton to get it to work and I also had to move the visibility part prior to the add button part.

 

After that it was loading the button to the mesh toolbar

 

TheCADnoob_0-1722349799553.png

 

 

Here is a link to someone adding a button to QAT but they used .net (edit: its the same link @paullimapa posted)

https://www.keanw.com/2010/04/adding-to-autocads-application-menu-and-quick-access-toolbar-using-net...

CADnoob

EESignature

Message 12 of 13
MRCH94D9W
in reply to: TheCADnoob

MRCH94D9W
Enthusiast
Enthusiast

It's an old piece of code I found in the company drawers. Unfortunately the author is not around anymore.

 

Any chance you can share your modifications to the code?

 

I have also seen the link previously posted. I just struggle to understand why adding a simple button should be that hard. The code also needs to be compiled, which I have no means of doing.

0 Likes

It's an old piece of code I found in the company drawers. Unfortunately the author is not around anymore.

 

Any chance you can share your modifications to the code?

 

I have also seen the link previously posted. I just struggle to understand why adding a simple button should be that hard. The code also needs to be compiled, which I have no means of doing.

Message 13 of 13
TheCADnoob
in reply to: MRCH94D9W

TheCADnoob
Mentor
Mentor

@MRCH94D9W wrote:
....

Any chance you can share your modifications to the code?

....

 

Here is what I changed it to. It should be noted that all i did was make it so that it would show up on the tool bar that it was placing it on. I still think the lisp isnt working as intended though. 

 

(defun c:AddBasicButton ()
(vl-load-com)
(setq acadObj (vlax-get-acad-object))
(setq doc (vla-get-ActiveDocument acadObj))

;; Macro for the command
(setq cmdMacro "^C^C_shell "C:/Users/myuser/test.bat";")

;; Get the Quick Access Toolbar
(setq menus (vla-get-MenuGroups acadObj))
(setq customToolbar (vla-Item (vla-get-Toolbars (vla-Item menus 0)) 0))

;; Ensure the toolbar is visible (typically QAT is always visible)
(vlax-put-property customToolbar 'Visible :vlax-true)

;; Add the button to the Quick Access Toolbar
(setq button (vla-AddToolbarButton customToolbar "RunMacroButton" "Run Macro" cmdMacro "true"))


;; Debug message
(princ "\nBasic button added to Quick Access Toolbar.")
(princ)
)

(c:AddBasicButton)

 

 

 

I have also seen the link previously posted. I just struggle to understand why adding a simple button should be that hard. The code also needs to be compiled, which I have no means of doing.


Its actually relatively easy to add things to the QAT for some things, but i think your parameters are making it a little more difficult. the QAT is also not a traditional toolbar which may be causing some confusion.  I personally would just add the command to the start up and users could access it via the command line. We also tend to use Pallets for our custom built tools. 

 

There are lots of things out there about managing company standards through customizing the interface. Id go check out some of the classes they have had at AU https://www.autodesk.com/autodesk-university/class/CAD-Managers-Guide-Using-Tool-Palettes-Manage-Sta...

CADnoob

EESignature


@MRCH94D9W wrote:
....

Any chance you can share your modifications to the code?

....

 

Here is what I changed it to. It should be noted that all i did was make it so that it would show up on the tool bar that it was placing it on. I still think the lisp isnt working as intended though. 

 

(defun c:AddBasicButton ()
(vl-load-com)
(setq acadObj (vlax-get-acad-object))
(setq doc (vla-get-ActiveDocument acadObj))

;; Macro for the command
(setq cmdMacro "^C^C_shell "C:/Users/myuser/test.bat";")

;; Get the Quick Access Toolbar
(setq menus (vla-get-MenuGroups acadObj))
(setq customToolbar (vla-Item (vla-get-Toolbars (vla-Item menus 0)) 0))

;; Ensure the toolbar is visible (typically QAT is always visible)
(vlax-put-property customToolbar 'Visible :vlax-true)

;; Add the button to the Quick Access Toolbar
(setq button (vla-AddToolbarButton customToolbar "RunMacroButton" "Run Macro" cmdMacro "true"))


;; Debug message
(princ "\nBasic button added to Quick Access Toolbar.")
(princ)
)

(c:AddBasicButton)

 

 

 

I have also seen the link previously posted. I just struggle to understand why adding a simple button should be that hard. The code also needs to be compiled, which I have no means of doing.


Its actually relatively easy to add things to the QAT for some things, but i think your parameters are making it a little more difficult. the QAT is also not a traditional toolbar which may be causing some confusion.  I personally would just add the command to the start up and users could access it via the command line. We also tend to use Pallets for our custom built tools. 

 

There are lots of things out there about managing company standards through customizing the interface. Id go check out some of the classes they have had at AU https://www.autodesk.com/autodesk-university/class/CAD-Managers-Guide-Using-Tool-Palettes-Manage-Sta...

CADnoob

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report