Author Topic: Toolbar location manipulation  (Read 10672 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.