Author Topic: Restoring visibility states and locations of toolbars using LISP  (Read 2536 times)

0 Members and 1 Guest are viewing this topic.

meinea

  • Mosquito
  • Posts: 4
Restoring visibility states and locations of toolbars using LISP
« on: February 16, 2019, 08:37:31 PM »
Hello everyone, and thank you in advance for any help provided.

Due to my company's setup and upgrades process and to streamline updating the installation build from one version of AutoCAD to the next, I'm trying to include most of our customizations in the form of "version free" LISP commands.

I need help with toolbars. To benefit from previous iterations of our setup, I'm using the toolbars portion of a profile .arg file, which looks something like this:
Code: [Select]
"ACAD.TB_INQUIRY"="show left 0 1"
"ACAD.TB_INSERT"="hide float 100 190 1"
And then can parse through this information to load and position the relevant toolbars accordingly.

I can handle the string parsing and was able to learn about loading and positioning the toolbars from :
https://www.cadtutor.net/forum/topic/2997-opening-a-toolbar-with-lisp-or-vba-in-2009/
The only issue that I'm still facing is that the .arg profile uses the toolbar alias name and the method explained in the mentioned thread uses the toolbar's actual name.

Any help would be much appreciated.
Thanks,

roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Restoring visibility states and locations of toolbars using LISP
« Reply #1 on: February 17, 2019, 03:16:04 AM »
Maybe you can use the TagString property of the toolbar object?
Code: [Select]
; IAcadToolbar 2a2629e8 : IAcadToolbar Interface
;
; Property values :
;
;   Application (RO) = #<VLA-OBJECT IAcadApplication 0000000015CE6EE0>
;   ...
;   Name = "Entity Snaps"
;   Parent (RO) = #<VLA-OBJECT IAcadToolbars 000000002A5FA958>
;   TagString (RO) = "tbEntitySnaps"
;   ...

meinea

  • Mosquito
  • Posts: 4
Re: Restoring visibility states and locations of toolbars using LISP
« Reply #2 on: February 17, 2019, 07:50:34 AM »
TagString seems to reflect the Element ID and not the Aliases

Code: [Select]
; IAcadToolbar: An AutoCAD toolbar
; Property values:
;   Application (RO) = #<VLA-OBJECT IAcadApplication 00007ff65f04b0a8>
;   Count (RO) = 14
;   DockStatus (RO) = 4
;   FloatingRows = 1
;   Height (RO) = AutoCAD: The toolbar is invisible. Please make it visible
;   HelpString = "\n    "
;   LargeButtons (RO) = 0
;   left = 100
;   Name = "Insert"
;   Parent (RO) = #<VLA-OBJECT IAcadToolbars 000002418b4a94c8>
;   TagString (RO) = "TB_0001"
;   top = 190
;   Visible = 0
;   Width (RO) = AutoCAD: The toolbar is invisible. Please make it visible



roy_043

  • Water Moccasin
  • Posts: 1895
  • BricsCAD 18
Re: Restoring visibility states and locations of toolbars using LISP
« Reply #3 on: February 17, 2019, 09:24:08 AM »
OK, it seems that BricsCAD has a slightly different behavior here.

Some additional ideas:
1.
Extract the required data from the CUI by also parsing that file.
2.
Hard-code a 'translation list'.
Code: [Select]
'(
  ("ACAD.TB_INQUIRY" . "Inquiry")
  ("ACAD.TB_INSERT" . "Insert")
  ...
)
3.
Create you own toolbar settings file instead of using an ARG file.

meinea

  • Mosquito
  • Posts: 4
Re: Restoring visibility states and locations of toolbars using LISP
« Reply #4 on: February 17, 2019, 11:56:25 AM »
Neat! For whatever reason it never crossed my mind to dig into the cui file.

Thank you for the idea!

BIGAL

  • Swamp Rat
  • Posts: 1410
  • 40 + years of using Autocad
Re: Restoring visibility states and locations of toolbars using LISP
« Reply #5 on: February 17, 2019, 05:10:17 PM »
I went down a different path and use lisp to set all paths, trusted locations and use menuload to load my menus and toolbars.

Just as a side note -toolbar allows manipulation of toolbars using Show opens a toolbar.
A man who never made a mistake never made anything

meinea

  • Mosquito
  • Posts: 4
Re: Restoring visibility states and locations of toolbars using LISP
« Reply #6 on: February 26, 2019, 07:21:52 AM »
I went down a different path and use lisp to set all paths, trusted locations and use menuload to load my menus and toolbars.

Just as a side note -toolbar allows manipulation of toolbars using Show opens a toolbar.

(command "toolbar") ended up doing a much better job organizing the toolbars in the right rows and columns compared with vla-dock.
Here's what I ended up doing:

1- I parsed the list of toolbars to something like this:
ACAD.Smooth Mesh.show.float.400.400.1
ACAD.Dimension.show.bottom.2.0
........
2- From that created a list of "line" items lists
3- Feeded it into a loop utilizing:
Code: [Select]
(if (= "FLOAT" (strcase d))
    (command "toolbar" (strcat a "." b) "float" (strcat e "," f) "1")
    (command "toolbar" (strcat a "." b) d       (strcat e "," f)))
a,b,c,d,e & f being the items of each "line" list

Thank you!

GDF

  • Water Moccasin
  • Posts: 2081
Re: Restoring visibility states and locations of toolbars using LISP
« Reply #7 on: February 26, 2019, 12:52:49 PM »
AutoCAD example:
(command "-toolbar" "STANDARD" "top" "0,0")

BricsCAD example:
(command "-toolbar" "STANDARD" "top" "0,0")
(command "-toolbar" "STANDARD" "show")
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2020x64 Windows 10x64