TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: GDF on February 22, 2020, 02:19:37 PM

Title: Remove a toolbar
Post by: GDF on February 22, 2020, 02:19:37 PM
How would I remove a toolbar without using a command:
(command "toolbar" "ARCH.Arch2Program©" "hide")

I want it to work thru a reactor...


Code - Auto/Visual Lisp: [Select]
  1. (defun C:RARCH ()
  2.   (princ "\n*** ---- Resetting ARCH Menu Pulldown ---- ***")
  3.   (cond
  4.     ((or (= (nth 0 (ARCH:Split (getvar "dwgprefix") "\\")) "Z:")(= (substr (getvar 'dwgname) 1 (- (strlen (getvar 'dwgname)) 5)) "Drawing"))
  5.       (ARCH:NotInDirectory))
  6.     ((or (/= (nth 0 (ARCH:Split (getvar "dwgprefix") "\\")) "Z:")(/= (substr (getvar 'dwgname) 1 (- (strlen (getvar 'dwgname)) 5)) "Drawing"))
  7.       (ARCH:InDirectory)))
  8.   [b];;(command "toolbar" "ARCH.Arch2Program©" "hide")[/b]
  9.   (princ))  
  10. ;;;
  11. (defun rarchit (calling-reactor commandinfo) (C:RARCH) (princ))
  12. (vlr-docmanager-reactor () '((:vlr-documentBecameCurrent . rarchit)))

EDIT (John): Added code tags.
Title: Re: Remove a toolbar
Post by: GDF on February 22, 2020, 02:57:16 PM
Code - Auto/Visual Lisp: [Select]
  1. (defun ax:Toggle (mGroup tBarName / tbar)
  2.   (if (= (vla-get-visible tbar) :vlax-true)
  3.     (vla-put-visible tbar :vlax-false)
  4.     (vla-put-visible tbar :vlax-true)
  5.   )
  6.   (princ))
  7.  
  8.  
  9. (ax:Toggle "ARCH" "Arch2Program©")

EDIT (John): Added code tags.
Title: Re: Remove a toolbar
Post by: GDF on February 22, 2020, 03:22:03 PM
I got this to work:

(defun ax:Toggle-off (mGroup tBarName / tbar)
  (setq tbar (vla-item (vla-get-toolbars (vla-item (vla-get-menugroups (vlax-get-acad-object)) mGroup)) tBarName))
  (if (= (vla-get-visible tbar) :vlax-true) (vla-put-visible tbar :vlax-false))
  (princ))
(defun ax:Toggle-on (mGroup tBarName / tbar)
  (setq tbar (vla-item (vla-get-toolbars (vla-item (vla-get-menugroups (vlax-get-acad-object)) mGroup)) tBarName))
  (if (= (vla-get-visible tbar) :vlax-false) (vla-put-visible tbar :vlax-true))
  (princ))
;;;
(defun C:RARCH ()
  (princ "\n*** ---- Resetting ARCH Menu Pulldown ---- ***")
  (ARCH:GDFstandard)
  (cond
    ((or (= (nth 0 (ARCH:Split (getvar "dwgprefix") "\\")) "Z:")(= (substr (getvar 'dwgname) 1 (- (strlen (getvar 'dwgname)) 5)) "Drawing"))
      (progn (ax:Toggle-off "ARCH" "Arch2Program©")(ARCH:NotInDirectory)))
    ((or (/= (nth 0 (ARCH:Split (getvar "dwgprefix") "\\")) "Z:")(/= (substr (getvar 'dwgname) 1 (- (strlen (getvar 'dwgname)) 5)) "Drawing"))
      (progn (ax:Toggle-on "ARCH" "Arch2Program©")(ARCH:InDirectory))))   
  (princ)) 
;;;
(defun rarchit (calling-reactor commandinfo) (C:RARCH) (princ))
(vlr-docmanager-reactor () '((:vlr-documentBecameCurrent . rarchit)))
Title: Re: Remove a toolbar
Post by: GDF on February 22, 2020, 03:25:30 PM
Well it works in BricsCAD but not AutoCAD.
Title: Re: Remove a toolbar
Post by: GDF on February 22, 2020, 09:37:59 PM
I found the error, a toolbar command call; which AutoCAD does not allow within a reactor.