muck Posted September 30, 2008 Share Posted September 30, 2008 AutoCAD version 2009. Is it possable to open a toolbar using lisp or vba in AutoCAD 2009? Is it possable to close a toolbar using lisp or vba in AutoCAD 2009? Can this be done to a group of toolbars at once Can the toolbars be called out by name? Thank you, Quote Link to comment Share on other sites More sharing options...
neekcotrack Posted September 30, 2008 Share Posted September 30, 2008 AutoCAD version 2009. Is it possable to open a toolbar using lisp or vba in AutoCAD 2009? Is it possable to close a toolbar using lisp or vba in AutoCAD 2009? Can this be done to a group of toolbars at once Can the toolbars be called out by name? Thank you, Yes you can open and close the toolbars to when the drawing is opened and closed. Quote Link to comment Share on other sites More sharing options...
ASMI Posted September 30, 2008 Share Posted September 30, 2008 Is it possable to open a toolbar using lisp or vba in AutoCAD 2009?Is it possable to close a toolbar using lisp or vba in AutoCAD 2009? Can this be done to a group of toolbars at once Can the toolbars be called out by name? Thank you, Yes it possible. For example you can to define function for tollbars togle: (defun ToolbarTogle(Menu Toolbar) (vl-load-com) (setq mCol(vla-get-MenuGroups (vlax-get-acad-object))) (if (not (vl-catch-all-error-p (setq mObj(vl-catch-all-apply 'vla-Item (list mCol Menu))))) (if (not (vl-catch-all-error-p (setq tObj(vl-catch-all-apply 'vla-Item (list(vla-get-Toolbars mObj)Toolbar))))) (if(= :vlax-true(vla-get-Visible tObj)) (vla-put-Visible tObj :vlax-false) (vla-put-Visible tObj :vlax-true) ); end if (princ(strcat "\n<!> Can't to find toolbar: " Toolbar " <!>")) ); end if (princ(strcat "\n<!> Can't to find menu group: " Menu " <!>")) ); end if (princ) ); end of ToolbarTogle Open/close "Modify" toolbar of standard "ACAD" group: (ToolbarTogle "ACAD" "Modify") Quote Link to comment Share on other sites More sharing options...
alanjt Posted October 1, 2008 Share Posted October 1, 2008 Yes it possible. For example you can to define function for tollbars togle: (defun ToolbarTogle(Menu Toolbar) (vl-load-com) (setq mCol(vla-get-MenuGroups (vlax-get-acad-object))) (if (not (vl-catch-all-error-p (setq mObj(vl-catch-all-apply 'vla-Item (list mCol Menu))))) (if (not (vl-catch-all-error-p (setq tObj(vl-catch-all-apply 'vla-Item (list(vla-get-Toolbars mObj)Toolbar))))) (if(= :vlax-true(vla-get-Visible tObj)) (vla-put-Visible tObj :vlax-false) (vla-put-Visible tObj :vlax-true) ); end if (princ(strcat "\n<!> Can't to find toolbar: " Toolbar " <!>")) ); end if (princ(strcat "\n<!> Can't to find menu group: " Menu " <!>")) ); end if (princ) ); end of ToolbarTogle Open/close "Modify" toolbar of standard "ACAD" group: (ToolbarTogle "ACAD" "Modify") very nice, i'm wondering, what's the coding to specify placement point for toolbar? Quote Link to comment Share on other sites More sharing options...
ASMI Posted October 1, 2008 Share Posted October 1, 2008 very nice, i'm wondering, what's the coding to specify placement point for toolbar? You can to use Float method to change toolbar position freely or Dock method to dock it in Top/Bottom/Left/Right screen side. Function with Float: (defun ToolbarPosition(Menu Toolbar Top Left) (vl-load-com) (setq mCol(vla-get-MenuGroups (vlax-get-acad-object))) (if (not (vl-catch-all-error-p (setq mObj(vl-catch-all-apply 'vla-Item (list mCol Menu))))) (if (not (vl-catch-all-error-p (setq tObj(vl-catch-all-apply 'vla-Item (list(vla-get-Toolbars mObj)Toolbar))))) (vla-Float tObj Top Left 1) (princ(strcat "\n<!> Can't to find toolbar: " Toolbar " <!>")) ); end if (princ(strcat "\n<!> Can't to find menu group: " Menu " <!>")) ); end if (princ) ); end of ToolbarPosition Move "Modify" toolbar to Top - 200 pixels and Left 50 pixels position: (ToolbarPosition "ACAD" "Modify" 200 50) Be carefull! You can move toolbar outside of screen area! Quote Link to comment Share on other sites More sharing options...
muck Posted October 1, 2008 Author Share Posted October 1, 2008 I tryed using the first routine but I find that the toolbars do not come back to their positions? I will try routine two. Is there a lisp routine that retains orginal toolbar postions? Quote Link to comment Share on other sites More sharing options...
muck Posted October 1, 2008 Author Share Posted October 1, 2008 Is there any routines that keep the toolbars in orginal postions when toolbars are toggle back on. The first two routines seem to move the toolbars??? Thank you, Quote Link to comment Share on other sites More sharing options...
ASMI Posted October 1, 2008 Share Posted October 1, 2008 I tryed using the first routine but I find that the toolbars do notcome back to their positions? The first function should not change toolbar position it only swich on/off toolbar visibility. Probably such effect exists in 2009. I unfortunately cannot check up it. I will try routine two. Is there a lisproutine that retains orginal toolbar postions? There isn't. Because position has not been kept where or. This is example code only. If you need you can to save old values of Top and Left properties to restore it in next session. For example: (setq oldTop(vla-get-Top tObj) oldLeft(vla-get-Left tObj) ); end setq Quote Link to comment Share on other sites More sharing options...
muck Posted October 1, 2008 Author Share Posted October 1, 2008 I think is depends on the order that the tool bars are removed. I think they shift up and out. I have been using the following to remove/insert tool bars. ;AUTOCAD 2009 TOOL BAR TOGGLE (DEFUN C:Tbar() (ToolbarTogle "ACAD" "Standard") (ToolbarTogle "EQUIP" "Tanks/Vessels/Pumps/Nozzles") (ToolbarTogle "EZ-PIPE" "Flanged Valves") (ToolbarTogle "STLPLUS" "SteelPlus VR14") (ToolbarTogle "ACAD" "Properties") (ToolbarTogle "ACAD" "Layers") (ToolbarTogle "ACAD" "Standard") (ToolbarTogle "ACAD" "Styles") (ToolbarTogle "ACAD" "Layers") (ToolbarTogle "ACAD" "WorkSpaces") (ToolbarTogle "ACAD" "Modify") (ToolbarTogle "ACAD" "View") '(ToolbarTogle "ACAD" "Draw Order") (If (= tg 1) (setq tg 0) (setq tg 1) ) (if (= tg 1) (command "ribbonclose") (command "ribbon") ) ) (defun ToolbarTogle(Menu Toolbar) (vl-load-com) (setq mCol(vla-get-MenuGroups (vlax-get-acad-object))) (if (not (vl-catch-all-error-p (setq mObj(vl-catch-all-apply 'vla-Item (list mCol Menu))))) (if (not (vl-catch-all-error-p (setq tObj(vl-catch-all-apply 'vla-Item (list(vla-get-Toolbars mObj)Toolbar))))) (if(= :vlax-true(vla-get-Visible tObj)) (vla-put-Visible tObj :vlax-false) (vla-put-Visible tObj :vlax-true) ); end if (princ(strcat "\n Can't to find toolbar: " Toolbar " ")) ); end if (princ(strcat "\n Can't to find menu group: " Menu " ")) ); end if (princ) ); end of ToolbarTogle (defun ToolbarTogleFIRST(Menu Toolbar) (vl-load-com) (setq mCol(vla-get-MenuGroups (vlax-get-acad-object))) (if (not (vl-catch-all-error-p (setq mObj(vl-catch-all-apply 'vla-Item (list mCol Menu))))) (if (not (vl-catch-all-error-p (setq tObj(vl-catch-all-apply 'vla-Item (list(vla-get-Toolbars mObj)Toolbar))))) (if(= :vlax-true(vla-get-Visible tObj)) (vla-put-Visible tObj :vlax-false) (vla-put-Visible tObj :vlax-true) ); end if (princ(strcat "\n Can't to find toolbar: " Toolbar " ")) ); end if (princ(strcat "\n Can't to find menu group: " Menu " ")) ); end if (princ) ); end of ToolbarTogle Quote Link to comment Share on other sites More sharing options...
ASMI Posted October 2, 2008 Share Posted October 2, 2008 I think you can use ToolbarSwich function instead ToolbarTogle function: (defun ToolbarSwich(Menu Toolbar Visible) (vl-load-com) (setq mCol(vla-get-MenuGroups (vlax-get-acad-object))) (if (not (vl-catch-all-error-p (setq mObj(vl-catch-all-apply 'vla-Item (list mCol Menu))))) (if (not (vl-catch-all-error-p (setq tObj(vl-catch-all-apply 'vla-Item (list(vla-get-Toolbars mObj)Toolbar))))) (if Visible (vla-put-Visible tObj :vlax-true) (vla-put-Visible tObj :vlax-false) ); end if (princ(strcat "\n<!> Can't to find toolbar: " Toolbar " <!>")) ); end if (princ(strcat "\n<!> Can't to find menu group: " Menu " <!>")) ); end if (princ) ); end of ToolbarSwich To swich on: (ToolbarSwich "ACAD" "Layers" T) To swich off: (ToolbarSwich "ACAD" "Layers" nil) And use FOREACH function for toolbar list. For example: (setq tLst(list "Properties" "Layers" "Standard" "Styles" "WorkSpaces")) Swich off all toolbar in list: (foreach tb tLst (ToolbarSwich "ACAD" tb nil) ) Swich on all toolbar in list: (foreach tb tLst (ToolbarSwich "ACAD" tb T) ) Quote Link to comment Share on other sites More sharing options...
muck Posted October 7, 2008 Author Share Posted October 7, 2008 with ToolbarSwich is still have tool bar shifting Whats the difference int ToolbarSwich and ToolbarTogle? Quote Link to comment Share on other sites More sharing options...
muck Posted October 7, 2008 Author Share Posted October 7, 2008 with ToolbarSwich is still have tool bar shifting Whats the difference int ToolbarSwich and ToolbarTogle? Quote Link to comment Share on other sites More sharing options...
ASMI Posted October 7, 2008 Share Posted October 7, 2008 Whats the differenceint ToolbarSwich and ToolbarTogle? If you read attentively will understand a difference... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.