Author Topic: Save&Restore toolbars position  (Read 6146 times)

0 Members and 1 Guest are viewing this topic.

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: Save&Restore toolbars position
« Reply #15 on: April 19, 2018, 10:31:25 AM »
Same as above in 2009.
Thanks for your time. I have tested in 2013. I will test on Bricscad.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Save&Restore toolbars position
« Reply #16 on: April 19, 2018, 12:46:37 PM »
I just hard code where I want the toolbars to be placed. If I want a different location, I just revise the code.


Code: [Select]
(defun C:GDF  ()
  (cond ((= "BRICSCAD" (strcase (getvar 'product)))(GDF:BricsCAD))
        ((/= "BRICSCAD" (strcase (getvar 'product)))(GDF:AutoCAD)))
  (princ))
;;;
(defun GDF:BricsCAD  ()
  (setvar "INTERFEREOBJVS" "")
  (setvar "INTERFEREVPVS" "")
  (setvar "plotoutputpath" (getvar "dwgprefix"))
  (setvar "cmddia" 1) ;command dialog box on
  (setvar "filedia" 1) ;file dialog box on   
  (setvar "pickbox" 5)
   (setvar "snapmode" 0)
  (princ "\n*** Fowler's Standard Preferences Settings ***")
  (command "toolbar" "ALL" "hide")
  (command "toolbar" "STANDARD" "show")
  (command "toolbar" "LAYERS" "show")
  (command "toolbar" "arch.arch_program" "show")
  (command "toolbar" "arch.arch_sset" "show")
  (command "toolbar" "arch.arch_toolpalette" "show")
  ;;
  (command "toolbar" "STANDARD" "top" "0,0")
  (command "toolbar" "LAYERS" "top" "515,0")
  (command "toolbar" "arch.arch_program" "top" "825,0")
  (command "toolbar" "arch.arch_sset" "top" "900,0")
  (command "toolbar" "arch.arch_toolpalette" "top" "950,0")
  (princ "\n***    Fowler's Standard Toolbar Setup     ***")
  (princ))
;;
(defun GDF:AutoCAD  ()
  (setenv "PlotToFilePath" (getvar "DWGPREFIX"))
  ;;(command "_-view" "_top")
  ;;(if (= (getvar "CTAB") "FullSize")(command "layout" "rename" "FullSize" "."))
  (setvar "cmddia" 1) ;command dialog box on
  (setvar "filedia" 1) ;file dialog box on
  ;;(command "-layer" "Plot" "N" "JUNK,*CODE*,*-AREA*,*-SF*" "")
  ;;(setenv "username" "GDF") 
  (if (> (getvar "ribbonstate") 0)
    (command "ribbonclose"))
  (if (tblsearch "layer" "Defpoints")
    (progn
      (if (or (= (getvar "clayer") "DEFPOINTS") (= (getvar "clayer") "Defpoints"))
        (command ".layer" "s" "0" ""))))
  (setvar "SHORTCUTMENU" 0) ;reset to autocad 14 behavior
  (setvar "aperture" 5)
  (setvar "pickbox" 5)
  (setvar "snapmode" 0)
  ;;(vla-put-displayscrollbars (vla-get-display (vla-get-preferences (vlax-get-acad-object))) :vlax-false)
  (princ "\n*** Fowler's Standard Preferences Settings ***")
  (setvar "cmdecho" 0)
  (setenv "CmdVisLines" "1")
  (command "toolbar" "ALL" "hide")
  (command "toolbar" "acad.TB_STANDARD" "show")
  (command "toolbar" "acad.TB_LAYER" "show")
  (command "toolbar" "arch.arch_program" "show")
  (command "toolbar" "arch.arch_sset" "show")
  (command "toolbar" "arch.arch_toolpalette" "show")
  ;;
  (command "toolbar" "acad.TB_STANDARD" "top" "0,0")
  (command "toolbar" "acad.TB_LAYER" "top" "515,0")
  (command "toolbar" "arch.arch_program" "top" "825,0")
  (command "toolbar" "arch.arch_sset" "top" "900,0")
  (command "toolbar" "arch.arch_toolpalette" "top" "950,0")
  (cond ((>= (distof (substr (getvar "acadver") 1 4)) 17.2)
         (setvar "menubar" 1)))
  (setvar "lockui" 5) 
  (princ "\n***    Fowler's Standard Toolbar Setup     ***")
  (princ))

Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: Save&Restore toolbars position
« Reply #17 on: April 19, 2018, 03:53:51 PM »

I just hard code where I want the toolbars to be placed. If I want a different location, I just revise the code.
...
Ok, I will test your method. Thanks.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Save&Restore toolbars position
« Reply #18 on: April 19, 2018, 04:25:04 PM »
Don't forget to FLOAT the toolbar first...
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64

Marc'Antonio Alessi

  • Swamp Rat
  • Posts: 1453
  • Marco
Re: Save&Restore toolbars position
« Reply #19 on: May 28, 2018, 03:44:28 PM »
It's been a while ... I tried a solution, this is the one that produces the best result but often you need to launch it several times to get the initial position  :x:
(try with at least two rows (ex bottom) and two columns (ex left))
Code: [Select]
(setq *AcadApp* (vlax-get-acad-object))
; New version 2018/05/30
;(ALE_Menu_ToolbarsSavePos)
;
(defun ALE_Menu_ToolbarsSavePos ( / TmpLst OutLst LspOut FilPnt TlbIdx TlbDck TlbTop TlbLft)
  (vlax-for MnuGrp (vla-get-MenuGroups *AcadApp*)
    (vlax-for VlaFor (vla-get-Toolbars MnuGrp)
      (setq
        TlbDck (vla-get-DockStatus VlaFor)   TlbLft (vla-get-left VlaFor)   TlbTop (vla-get-top  VlaFor)
        TlbIdx (atoi (strcat (itoa TlbDck) (itoa TlbLft) (itoa TlbTop)))
        TmpLst (cons (list TlbIdx (vla-get-name VlaFor) TlbDck TlbLft TlbTop (= :vlax-true (vla-get-visible VlaFor))) TmpLst)
      )
    )
    (setq
      TmpLst (vl-sort TmpLst '(lambda (a b) (> (car a) (car b))))
      OutLst (cons (cons (strcase (vla-get-name MnuGrp)) TmpLst) OutLst)
      TmpLst nil
    )
  )
  (and
    OutLst
    (progn
      (setq FilPnt (open (setq LspOut "Z:\\Temp\\$Cfg_Menu.lsp") "w"))
      (princ "'" FilPnt) (princ (vl-prin1-to-string (reverse OutLst)) FilPnt)
      (close FilPnt)
      (alert (strcat "Asso message:\n\nPosizione Toolsbars salvata nel File: " LspOut))
    )
  )
  (princ)
)
;
;(repeat 5 (ALE_Menu_ToolbarsRecoverPos))
;
(defun ALE_Menu_ToolbarsRecoverPos ( / MnuGrp TlbInf MnuObj TbsObj TlbObj PosInf)
  (setq
    MnuGrp (vla-get-menugroups *AcadApp*)
    TlbInf (load "Z:\\Temp\\$Cfg_Menu.lsp")
    PosLst '((0 . "_TOP") (1 . "_BOTTOM") (2 . "_LEFT") (3 . "_RIGHT") (4 . "_FLOAT"))
  )
  (foreach ForMnu TlbInf
    (and
      (cdr ForMnu)
      (setq MnuObj (ALE_Utl_GetItem MnuGrp (car ForMnu)))
      (setq TbsObj (vla-get-Toolbars MnuObj))
      (foreach ForElm (cdr ForMnu)
        (if (setq TlbObj (ALE_Utl_GetItem TbsObj (cadr ForElm)))
          (progn
            (if (nth 5 ForElm)
              (progn
                (vla-put-visible TlbObj :vlax-true)
                (setq PosInf (assoc (caddr ForElm) PosLst))
                (vla-Float TlbObj 0 0 1)
                (if (or #BCFlg (/= 4 (car PosInf)))
                  (command "_TOOLBAR" (cadr ForElm) (cdr PosInf) (strcat (itoa (cadddr ForElm)) "," (itoa (nth 4 ForElm))))
                  (command "_TOOLBAR" (cadr ForElm) (cdr PosInf) (strcat (itoa (cadddr ForElm)) "," (itoa (nth 4 ForElm))) "1")
;                 (or (= (vla-get-DockStatus TlbObj) (caddr ForElm))  (vla-Dock TlbObj (caddr ForElm)))
;                 (vla-put-left TlbObj (cadddr ForElm)) (vla-put-top TlbObj (nth 4 ForElm)) ; not used
                )
              )
              (vla-put-visible TlbObj :vlax-false)
            )
          )
          (vla-put-visible TlbObj :vlax-false)
        )
      )
    )
  )
  (princ)
)
Edit: New version 2018/05/30