Author Topic: Toolbar location manipulation  (Read 10671 times)

0 Members and 1 Guest are viewing this topic.

T.Willey

  • Needs a day job
  • Posts: 5251
Toolbar location manipulation
« on: June 19, 2006, 11:51:23 AM »
Has anyone been able to change the location of the toolbars using code?  For some reason, my settings are not getting saved from day to day, and it has to do with my company's setup.  They know about the problem, but I don't know when the fix will come.  I have my menus setup by a lisp routine that I wrote, with some code by others, but I can't seem to figure out how to have my toolbars located the way I want them to be.  I'm using ActiveX for this, but if dxf codes (not sure about these for this purpose) is easier to use, I am willing to try them.

Thanks, and any help is appreciated.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Bob Wahr

  • Guest
Re: Toolbar location manipulation
« Reply #1 on: June 19, 2006, 11:56:28 AM »
I've done it with VBA but it was quite a while back.  I don't remember it not saving the settings but it might not have.  It was a path I went down briefly then scrapped for something else.

Chuck Gabriel

  • Guest
Re: Toolbar location manipulation
« Reply #2 on: June 19, 2006, 12:29:41 PM »
I'm guessing you guys must have an enforced profile that overwrites the HKEY_CURRENT_USER section of your registry when you log on.

If that is the case, here is an excerpt from my registry that may help you.

Jeff_M

  • King Gator
  • Posts: 4096
  • C3D user & customizer
Re: Toolbar location manipulation
« Reply #3 on: June 19, 2006, 12:34:30 PM »
Tim,
If this is for 2006 (I think I recall you saying that you recently moved up from 2004) you will need to save your Workspace whenever you change a location of a toolbar in order for it to 'stick' between sessions.

Here's an example of putting Toolbars where you want:
Code: [Select]
(setq menus (vla-get-menugroups (vlax-get-acad-object)))
(setq menu (vla-item menus "ACAD"))
(setq tbs (vla-get-toolbars menu))
(setq tb (vla-item tbs "WORKSPACES"));;use a toolbar that is visible & not docked
(setq top (vla-get-top tb)
      left (vla-get-left tb))
(princ (strcat (itoa left) "  -  " (itoa top)))
(vla-put-top tb (+ top 100)) ;;+ is down, - is up
(vla-put-left tb (- left 100))
(setq top (vla-get-top tb)
      left (vla-get-left tb))
(princ (strcat (itoa left) "  -  " (itoa top)))

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Toolbar location manipulation
« Reply #4 on: June 19, 2006, 01:01:36 PM »
I'm guessing you guys must have an enforced profile that overwrites the HKEY_CURRENT_USER section of your registry when you log on.

If that is the case, here is an excerpt from my registry that may help you.
Thanks Chuck.  I think that is happening, but that is what they are trying to fix right now, as this didn't happen with 2004.  I don't want to edit the registry, but I will keep this in mind.

Tim,
If this is for 2006 (I think I recall you saying that you recently moved up from 2004) you will need to save your Workspace whenever you change a location of a toolbar in order for it to 'stick' between sessions.

Here's an example of putting Toolbars where you want:
Code: [Select]
(setq menus (vla-get-menugroups (vlax-get-acad-object)))
(setq menu (vla-item menus "ACAD"))
(setq tbs (vla-get-toolbars menu))
(setq tb (vla-item tbs "WORKSPACES"));;use a toolbar that is visible & not docked
(setq top (vla-get-top tb)
      left (vla-get-left tb))
(princ (strcat (itoa left) "  -  " (itoa top)))
(vla-put-top tb (+ top 100)) ;;+ is down, - is up
(vla-put-left tb (- left 100))
(setq top (vla-get-top tb)
      left (vla-get-left tb))
(princ (strcat (itoa left) "  -  " (itoa top)))

This is for 2006, but I'm working with docked toolbars, and I haven't been able to rearrange them once the come in in the wrong location.

Here is the whole situation.  I have two custom menus that I load.  It seems that my company is not saving my profile to the correct location at the end of the day (I can't fix that), or when my computer is shut down.  So I figured I would just write a routine to load my menus, and then setup my toolbars the way I like.  The loading of my menus works fine.  I hide all toolbars, and then just make visible the ones I want.  They start in the docked location, which is fine, but i can't move them where I want to with code.

Thanks for the help, and sorry if I didn't explain myself very well.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Toolbar location manipulation
« Reply #5 on: June 19, 2006, 01:31:08 PM »
I have tried to float them all, and then put them back into docked position correctly, but that didn't work either.  It seems you can't move docked toolbars, and you can't assign the correct locations before you dock them.

If anyone has any other ideas, I'm willing to try.  Thanks.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Dinosaur

  • Guest
Re: Toolbar location manipulation
« Reply #6 on: June 19, 2006, 01:42:04 PM »
If you are using only one monitor, you can set your main screen to not be maximized.  This will let you leave enough room at the perimeters to put a toolbar outside the drawing area and not be docked.  If you are using dual monitors, I have found toolbar locations to be more stable if I put the main screen on the secondary monitor and toolbars on the primary.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Toolbar location manipulation
« Reply #7 on: June 19, 2006, 02:28:07 PM »
I have tried to float them all, and then put them back into docked position correctly, but that didn't work either.  It seems you can't move docked toolbars, and you can't assign the correct locations before you dock them.

If anyone has any other ideas, I'm willing to try.  Thanks.

Tim

Floating the toolbars and then docking them has worked for me.

Try the following:
(command "toolbar" "acad.TB_OBJECT_PROPERTIES" "float" "100,100" "1")
(command "toolbar" "acad.TB_OBJECT_PROPERTIES" "top" "800,1")

Works here, even for locked toolbars and dual monitors.

Gary



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

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Toolbar location manipulation
« Reply #8 on: June 19, 2006, 03:19:43 PM »
If you are using only one monitor, you can set your main screen to not be maximized.  This will let you leave enough room at the perimeters to put a toolbar outside the drawing area and not be docked.  If you are using dual monitors, I have found toolbar locations to be more stable if I put the main screen on the secondary monitor and toolbars on the primary.
Good points Dinosaur (don't know how to make the other symbol).  I do have dual monitors, but going from one to the other is just too much movement; I don't have that much room for mouse movement.  The other idea would work, I would just have to get used to it again.

I have tried to float them all, and then put them back into docked position correctly, but that didn't work either.  It seems you can't move docked toolbars, and you can't assign the correct locations before you dock them.

If anyone has any other ideas, I'm willing to try.  Thanks.

Tim

Floating the toolbars and then docking them has worked for me.

Try the following:
(command "toolbar" "acad.TB_OBJECT_PROPERTIES" "float" "100,100" "1")
(command "toolbar" "acad.TB_OBJECT_PROPERTIES" "top" "800,1")

Works here, even for locked toolbars and dual monitors.

Gary

It seems I have to go the command route, as I tried to do it code way, but that didn't work.  Thanks Gary.  I learned a new command today.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Toolbar location manipulation
« Reply #9 on: June 19, 2006, 03:30:36 PM »
Tim

This works also...

Code: [Select]
;;;Turns off Visible toolbars
;;;Caution: ToolBars do not always get restored in same location.
;;;Import previously saved profile (.arg) will restore to previous location.
;;;by BillZ
(defun c:ToolBarsOff  (/ names *acad* adoc)
  (vl-load-com)
  (setq *acad* (vlax-get-acad-object)
        adoc   (vla-get-activedocument *acad*))
  (vla-put-windowstate *acad* 1)
  (vla-put-windowstate adoc 3)
  (setq MenGrps (vla-get-menugroups *acad*))
  (vlax-for item MenGrps (setq names (cons (vla-get-name item) names)))
  (foreach
         n  names
    (vlax-for
           item  (vla-get-toolbars (vla-item MenGrps n))
      (if (= (vla-get-visible item) :vlax-true)
        (progn (setq VisList (cons item VisList))
               (vla-put-visible item :vlax-false)))))   
  (princ))
(defun c:ToolBarsOn  (/ names *acad* adoc)
  (vl-load-com)
  (setq *acad* (vlax-get-acad-object)
        adoc   (vla-get-activedocument *acad*))
  (vla-put-windowstate *acad* 1)
  (vla-put-windowstate adoc 3)
  (setq MenGrps (vla-get-menugroups *acad*))
  (vlax-for item MenGrps (setq names (cons (vla-get-name item) names)))
  (foreach
         n  names
    (vlax-for
           item  (vla-get-toolbars (vla-item MenGrps n))
      (if (= (vla-get-visible item) :vlax-true)
        (progn (setq VisList (cons item VisList))
               (vla-put-visible item :vlax-false)))))
    (foreach n VisList ;to turn toolbars visible.
    (vla-put-visible n :vlax-true)
    )
  (princ))

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

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Toolbar location manipulation
« Reply #10 on: June 19, 2006, 03:40:46 PM »
Those routines are just to turn on/off toolbars.  I have those types already.  What I don't have is a way through Lisp/VLisp/ActiveX code to place them in the right location.  With your help, I am doing it the command route, which seems to work fine.

Thanks again Gary.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

LE

  • Guest
Re: Toolbar location manipulation
« Reply #11 on: June 19, 2006, 03:53:59 PM »

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Toolbar location manipulation
« Reply #12 on: June 19, 2006, 04:02:19 PM »
Might be this mickey mouse code?

http://www.theswamp.org/index.php?topic=9441.msg132809#msg132809
Thanks Luis, but that doesn't seem to be what I'm trying to do either, but I was thinking of doing something like that today. :-)

I tried doing it that way but with Docked toolbars instead of floating, and they didn't work for me.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

LE

  • Guest
Re: Toolbar location manipulation
« Reply #13 on: June 19, 2006, 04:16:30 PM »
Thanks Luis, but that doesn't seem to be what I'm trying to do either, but I was thinking of doing something like that today. :-)

I tried doing it that way but with Docked toolbars instead of floating, and they didn't work for me.

I see;

I remember that Phil Kreiker in a very old section of a magazine, he wrote a tool (in lisp) for something like what you are asking.... but I am not sure, the few brain cells left are not to good anymore  :roll:.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Toolbar location manipulation
« Reply #14 on: June 19, 2006, 04:47:58 PM »
Thanks Luis, but that doesn't seem to be what I'm trying to do either, but I was thinking of doing something like that today. :-)

I tried doing it that way but with Docked toolbars instead of floating, and they didn't work for me.

I see;

I remember that Phil Kreiker in a very old section of a magazine, he wrote a tool (in lisp) for something like what you are asking.... but I am not sure, the few brain cells left are not to good anymore  :roll:.
Maybe I will try some plain ol' lisp stuff, and see if I can find anything out.  Thanks for the lead Luis.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Toolbar location manipulation
« Reply #15 on: June 19, 2006, 05:26:46 PM »
I couldn't find anything lisp, so far.  But I did find something in the help, that makes it look like you can with VBA.
Quote from: Acad Help
To dock a toolbar, use the Dock method for the toolbar. The Dock method takes three parameters as input: Side, Row, and Column. The Side parameter specifies the side of the toolbar that you will be positioning in the docking maneuver. You can specify the top, bottom, left, or right side of the toolbar. The Row and Column parameters specify a number on the existing rows and columns of docked toolbars at which to dock the toolbar.

You can query a toolbar to see if it is docked by using the DockStatus property. The DockStatus property will return TRUE if the toolbar is docked and FALSE if the toolbar is floating.

Dock a toolbar
But you can't do it with ActiveX controls through lisp.
Quote from: Acad Command Line
Command: (VLA-DOCK (CADDR TBLIST) acToolbarDockTop 0 0)
; error: Too many actual parameters

Command: (vlax-invoke (caddr tblist) 'Dock acToolbarDockTop 0 0)
; error: Invalid number of parameters

Command: (vlax-invoke (caddr tblist) 'Dock acToolbarDockTop 0,0)
; error: Invalid number of parameters

Command: (vlax-invoke (caddr tblist) 'Dock acToolbarDockTop "0,0")
; error: Invalid number of parameters

Command: (vlax-invoke (caddr tblist) 'Dock acToolbarDockTop)
nil
Off to find some more good things.  If anyone wants to test this in VBA and let me know, that would be cool.  I don't think I would use it, as I know NOTHING in VBA, but just that it can or can't would be nice to know.

Thanks.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

LE

  • Guest
Re: Toolbar location manipulation
« Reply #16 on: June 19, 2006, 05:37:41 PM »
Here is a sample (To test move the dimension toolbar to any place on your screen, then call the code below):

Code: [Select]
(setq toolbar "dimension")
(vla-dock
  (vla-item
    (vla-get-toolbars
      (vla-item
(vla-get-menugroups (vlax-get-acad-object))
"ACAD"))
    toolbar)
  acToolbarDockTop)

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Toolbar location manipulation
« Reply #17 on: June 19, 2006, 05:49:50 PM »
Here is a sample (To test move the dimension toolbar to any place on your screen, then call the code below):

Code: [Select]
(setq toolbar "dimension")
(vla-dock
  (vla-item
    (vla-get-toolbars
      (vla-item
(vla-get-menugroups (vlax-get-acad-object))
"ACAD"))
    toolbar)
  acToolbarDockTop)
This works, but you can't specify the location you want that toolbar to be docked at.  At least I haven't found a way to do it yet.  When you run your code, it will bring it up. Then you move it, but when you dock it, it will always be on the top, and to the left.  Try placing it on the second row and be the second one to the left with code, and that is what I'm trying to do, and can't do yet.  I'm still trying though.  Hope that explains a little better what I'm trying to do.

Thanks.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Bob Wahr

  • Guest
Re: Toolbar location manipulation
« Reply #18 on: June 19, 2006, 05:58:29 PM »
Just a thought, make a list of all of the toolbars from bottom right to top left, then dock each toolbar to the top in order. It might work, probably won't though.  I'm guessing it will give one long row that goes off screen.  I don't have time now but will try VBA when I do if someone doesn't beat me.

LE

  • Guest
Re: Toolbar location manipulation
« Reply #19 on: June 19, 2006, 06:05:49 PM »
This works, but you can't specify the location you want that toolbar to be docked at.  At least I haven't found a way to do it yet.  When you run your code, it will bring it up. Then you move it, but when you dock it, it will always be on the top, and to the left.  Try placing it on the second row and be the second one to the left with code, and that is what I'm trying to do, and can't do yet.  I'm still trying though.  Hope that explains a little better what I'm trying to do.

Thanks.

I know... I was giving you the sample about how to call vla-dock....

As far all the test I just did, by calculating the pixels locations for the toolbar's it does not put them back to where they supposed to be placed... using the vla-put-top and vla-put-left...  no more time to play for now.

GDF

  • Water Moccasin
  • Posts: 2081
Re: Toolbar location manipulation
« Reply #20 on: June 19, 2006, 06:14:51 PM »
Tim

Look at the TBU routine enclosed. I have found that to get toolbars to dock where you want them using the toolbar command you have to do a little song and dance.

I could use a more elgant approach....

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

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Toolbar location manipulation
« Reply #21 on: June 19, 2006, 06:18:21 PM »
Just a thought, make a list of all of the toolbars from bottom right to top left, then dock each toolbar to the top in order. It might work, probably won't though.  I'm guessing it will give one long row that goes off screen.  I don't have time now but will try VBA when I do if someone doesn't beat me.
Yup Bob, just one big line.

This works, but you can't specify the location you want that toolbar to be docked at.  At least I haven't found a way to do it yet.  When you run your code, it will bring it up. Then you move it, but when you dock it, it will always be on the top, and to the left.  Try placing it on the second row and be the second one to the left with code, and that is what I'm trying to do, and can't do yet.  I'm still trying though.  Hope that explains a little better what I'm trying to do.

Thanks.

I know... I was giving you the sample about how to call vla-dock....

As far all the test I just did, by calculating the pixels locations for the toolbar's it does not put them back to where they supposed to be placed... using the vla-put-top and vla-put-left...  no more time to play for now.

Okay, Thanks Luis.  I have search the web, and the help, and haven't found a way to do it with lisp yet.  I'm just about to give up on this one.

Thanks to everyone who particapted in this thread, or will.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Toolbar location manipulation
« Reply #22 on: June 19, 2006, 06:28:11 PM »
Tim

Look at the TBU routine enclosed. I have found that to get toolbars to dock where you want them using the toolbar command you have to do a little song and dance.

I could use a more elgant approach....

Gary
Thank Gary.  I just looked at your routine, and it looks like what I'm doing.  I have to use "comamnd" to place my toolbars in the right locations, but I use code to hide all the ones I don't want to see.

Code: [Select]
(defun HideAllToolbars ()

(vlax-for Menu (vla-get-MenuGroups (vlax-get-Acad-Object))
 (vlax-for TlBar (vla-get-ToolBars Menu)
  (vla-put-Visible TlBar :vlax-False)
 )
)
)
Then I turn on the ones I want to use.
Example:
Code: [Select]
(setq AcadObj (vlax-get-Acad-Object))
(setq MnGrp (vla-get-MenuGroups AcadObj))
(vla-put-Visible (vla-Item (vla-get-ToolBars (vla-Item MnGrp "ACAD")) "Workspaces") :vlax-true)
Then I float all the visible toolbars
Code: [Select]
(FloatToolbars (GetAllVisibleToolbars))


(defun GetAllVisibleToolbars (/ TbList)

(vlax-for Menu (vla-get-MenuGroups (vlax-get-Acad-Object))
 (vlax-for TlBar (vla-get-ToolBars Menu)
  (if (= (vla-get-Visible TlBar) :vlax-true)
   (setq TbList (cons TlBar TbList))
  )
 )
)
TbList
)

(defun FloatToolbars (TbList / Top Left)

(setq Top 50)
(setq Left 1100)
(foreach Tb TbList
 (vla-Float Tb Top Left (vla-get-Count Tb))
 (setq Top (+ Top 50))
)
(princ)
)
Then I use the "command" to place them.
Code: [Select]
(if (= ElectOpt "No")
 (progn
  (command "_.toolbar" "T-Standard" "_top" "0,0")
  (command "_.toolbar" "My-Layers" "_top" "1,0")
  (command "_.toolbar" "Workspaces" "_top" "2,0")
 )
 (progn
  (command "_.toolbar" "ACE:Main Electrical" "_top" "0,0")
  (command "_.toolbar" "ACE:Main Electrical 2" "_top" "1,0")
  (command "_.toolbar" "Workspaces" "_top" "2,0")
  (command "_.toolbar" "T-Standard" "_top" "0,1")
  (command "_.toolbar" "My-Layers" "_top" "1,1")
 )
)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

sinc

  • Guest
Re: Toolbar location manipulation
« Reply #23 on: June 21, 2006, 08:45:07 AM »
So then is this whole problem being caused by the fact that your company is trying to use a "company-wide profile", that everyone shares?

That's incorrect usage of profiles, and it leads to huge headaches like this.  If your company started using profiles correctly, your problems would undoubtedly melt away, and no need for all this roundabout mumbojumbo.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: Toolbar location manipulation
« Reply #24 on: June 21, 2006, 11:12:51 AM »
It just happened when we went to 2006.  The company provides profiles to start with, then we can change them to suite our needs, which worked fine in 2004.  They know about the problem, but it doesn't look like it is a high priority right now, which is why I did this work around.

To clarify.
Yes they use specific company wide profiles.
But one can change them, and in theory, have them remain changed until upgrade or you overwrite them back the the standard ones yourself.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.