Author Topic: Get flyout value  (Read 4080 times)

0 Members and 1 Guest are viewing this topic.

ScottBolton

  • Guest
Re: Get flyout value
« Reply #15 on: February 16, 2013, 05:26:32 AM »
Ok, I'm using XRecords for other things so your suggestion could work. But...

I would be prompted for a region with each new drawing I create 'cause there's no XRecord in it yet, even though I'm only working on FR projects at the moment. At least by storing a variable outside of AutoCAD my functions could reference that text file - an XRecord could even be written at this point.

I really need something to say, from the moment FR is selected use this region until it is changed, no matter how many new drawings are created or how much time goes by. And ideally I need this region displayed somehow.

Incidentally, irneb's code fails on "; error: Automation Error. Invalid argument UK-ON.bmp in SetBitmap". I'll look into it further today...

S

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Get flyout value
« Reply #16 on: February 16, 2013, 06:48:47 AM »
You don't really need a file for that. You can much more simply store your settings into the registry using setenv: http://www.cadtutor.net/forum/showthread.php?61283-Environment-Variables&p=416434&viewfull=1#post416434

Simply put, your ACadDoc.LSP would contain some code to run per DWG opened. It checks to see if the XRecord exists - if so it sets the "current" country by highlighting the correct button and setting the flyout's icon accordingly. If it doesn't exist then check your global setting using getenv, if that exists then set the buttons according to that and save into the DWG's XRecord. If that also doesn't exist, it means the user's never before clicked any of your buttons - so you need to decide on a default (perhaps derived from the (getvar "LACALE").

Then your code for clicking one of the flag buttons would do the following:
  • Highlight the button's icon as per my previous code.
  • Set the flyout button's icon to the same.
  • Save the country code to the DWG's XRecord.
  • Save the country code to the registry also (using setenv) to store the last country selected as default
  • Set the global variable to the country code for quick access in your other codes
There's one issue though: What if the user has more than one DWG open at the same time, and (at least) one of those has a different country code set in its XRecord? You might need to incorporate a docmanager reactor to check if documentToBeActivated, then also documentBecameCurrent. If both those happened on the same DWG, then you would need to re-read the XRecord and set the buttons accordingly.

If you want your app to work on other cads where there is no registry (e.g. BricsCAD on Linux / AutoCAD on Mac), then I'd go with a settings file in one of the support folders. But if you need to cater for such non-windows cads, these routines won't work anyway - since you would not have the vla / vlax functions available.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

ScottBolton

  • Guest
Re: Get flyout value
« Reply #17 on: February 19, 2013, 03:41:31 PM »
irneb,

'pologies for the delay - I've been a little under the weather this weekend.

Your work process makes sense and setting an environment variable, with whatever checks in place, seems the way to go. My only problem is, and was the original problem (but I don't mean to be rude!), I can't get the toolbar button image to change.  When I load your code and hit the flyout I get

; error: Automation Error. Invalid argument FR-OFF.bmp in SetBitmap

Even if I use an AutoCAD image I still get the error. I've been able to (vla-SetBitmaps and (vla-GetBitmaps shows that the image is changed but this isn't reflected on screen. I've even tried hiding then showing the toolbar but it still shows the original image.

S

BlackBox

  • King Gator
  • Posts: 3770
Re: Get flyout value
« Reply #18 on: February 19, 2013, 03:44:54 PM »
Building on the last post....

Don't forget to incorporate a DocManager Reactor, so that when you switch between multiple open Documents, and the :vlr-DocumentBecameCurrent Event is raised, the Bitmap reflects _that_ Document's assigned country/region, etc.
"How we think determines what we do, and what we do determines what we get."

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Get flyout value
« Reply #19 on: February 20, 2013, 01:24:41 AM »
My only problem is, and was the original problem (but I don't mean to be rude!), I can't get the toolbar button image to change.  When I load your code and hit the flyout I get

; error: Automation Error. Invalid argument FR-OFF.bmp in SetBitmap
Nothing "rude" about it  ;)


What version / vertical of ACad are you using? Sorry if I missed it from a previous post. It works perfectly fine for me ACad Vanilla 2013 and ACA 2013. Did you load the cuix file as a partial and load the LSP?
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

ScottBolton

  • Guest
Re: Get flyout value
« Reply #20 on: February 20, 2013, 04:16:52 AM »
Now then,

Civil 3D 2013 (as AutoCAD 2013) [SP1].

I've now moved Countries.cuix into Support and although I don't get an error message I also don't get a change in icon.

S(ad)

ScottBolton

  • Guest
Re: Get flyout value
« Reply #21 on: February 22, 2013, 03:44:37 PM »
Ok, some developments. Although both ON and OFF flags were on the toolbars it appears that the BMPs also needed to be in the Support path; putting them there got the code from irneb to work.

However, as can be seen from the attached image, the bitmaps only change on a static toolbar. I can pick a button - either on the static or flyout - and the images change on the static but not on the flyout. Ideas?

S

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Get flyout value
« Reply #22 on: February 23, 2013, 01:32:26 AM »
You're correct, the flyout never updates. But I can get the flyout "button" to update:
Code - Auto/Visual Lisp: [Select]
  1. (defun Countries:FlagIcon  (Code / checkBtn name icon)
  2.   (defun checkBtn  (btn)
  3.     (if (wcmatch (setq name (vla-get-Name btn)) "Flag*")
  4.       (progn (cond ((wcmatch name (strcat "*" Code))
  5.                     (setq *CountryCode* Code
  6.                           icon          (strcat Code "-ON.bmp")))
  7.                    ((wcmatch name "*Country") (setq icon (strcat Code "-ON.bmp")))
  8.                    (t (setq icon (strcat (substr name 5) "-OFF.bmp"))))
  9.              (vla-SetBitmaps btn icon icon))))
  10.     (vlax-for item  tb
  11.       (cond ((= (vla-get-Type item) 3)
  12.              (checkBtn item)
  13.              (vlax-for btn (vla-get-FlyOut item) (checkBtn btn)))
  14.             (t (checkBtn item)))))
  15.   (princ))
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

ScottBolton

  • Guest
Re: Get flyout value
« Reply #23 on: March 04, 2013, 02:00:52 PM »
irneb,

Still can't get the flyout images to change. I've opted to show all the regions on a static toolbar, turning the unused ones "off". As per your, and BlackBox's, suggestions I will use XRecords in the drawing as the first storage point then if none exists I will use an environment variable.

Thanks for all your help.

S

owenwengerd

  • Bull Frog
  • Posts: 451
Re: Get flyout value
« Reply #24 on: March 04, 2013, 03:36:27 PM »
If you can't get the toolbar working the way you want, you may find it easier to use a status bar button. You could use the AcadStatButton COM interface to control it from lisp.

ScottBolton

  • Guest
Re: Get flyout value
« Reply #25 on: March 05, 2013, 11:26:09 AM »
Just when I thought it was safe to go back in the programming pool!