Author Topic: global variable  (Read 1849 times)

0 Members and 1 Guest are viewing this topic.

wizman

  • Bull Frog
  • Posts: 228
global variable
« on: March 04, 2008, 03:31:28 AM »
hi to all,

is there a way i can make my variable global after restarting acad?

 

CADmium

  • Newt
  • Posts: 33
Re: global variable
« Reply #1 on: March 04, 2008, 04:08:49 AM »
..you can use (and modify) the acaddoc.lsp to set a variable in each drawing , or vl-bb-ref /vl-bb-set to use the blackboard namespace ..
"Bei 99% aller Probleme ist die umfassende Beschreibung des Problems bereits mehr als die Hälfte der Lösung desselben."

wizman

  • Bull Frog
  • Posts: 228
Re: global variable
« Reply #2 on: March 04, 2008, 04:27:12 AM »
.. or vl-bb-ref /vl-bb-set to use the blackboard namespace ..

i'll look into that, thanks cadmium

wizman

  • Bull Frog
  • Posts: 228
Re: global variable
« Reply #3 on: March 04, 2008, 05:37:30 AM »
I tried that cadmium(thank for the vl-bb-ref/set function) but it works only for one acad session, once i restart, its back to nil again,
my real goal/intent for this one is to have a check mark toggle in my pull down menu, im able to
toggle check and uncheck the pull down menu whenever a menu is loaded. But the problem is the checkmark
disappears once i restart acad and comes again when i toggle menus. ive seen this function:

$(if,$(and,$(getvar,lightglyphdisplay),1),!.)&Lights

in the cui of acad in lights, this does the checkmark even acad restarts,
this one works due to lightglyphdisplay system variable is set to 1,
what im thinking is to have a user-defined system variable or a global variable like this:
 


Code: [Select]
$(if,$(and,$(getvar,*myglobal_variable*),1),!.)&mypulldown
i searched through this forum, and found maybe writing in registry may do the trick but im not familiar with it yet,
got any ideas/simple example how i can do it that way anyone?thanks

GDF

  • Water Moccasin
  • Posts: 2000
Re: global variable
« Reply #4 on: March 04, 2008, 09:50:50 AM »
hi to all,

is there a way i can make my variable global after restarting acad?

 

I save mine to windows registry using:

  vl-registry-write

and then retrieve them with:

  vl-registry-read
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2019x64 Windows 10x64

wizman

  • Bull Frog
  • Posts: 228
Re: global variable
« Reply #5 on: March 04, 2008, 10:01:00 AM »
Thanks gary, ill have a look at those functions in the developer help.

FengK

  • Guest
Re: global variable
« Reply #6 on: March 04, 2008, 11:39:34 AM »
I tried that cadmium(thank for the vl-bb-ref/set function) but it works only for one acad session, once i restart, its back to nil again,

wizman, i think what CADmium suggested was you modify the acaddoc.lsp file (or any other .lsp file what's always loaded in each opened drawing). For example: appending a line like
"(setq glb::radius 20.0)" at the end of the lisp file, and next time a drawing is opened, a variable named glb::radius will be set to 20.0 in that drawing. If you're taking this approach, I would put such variable-setting codes in a separate lsp file, say SetGlobalLispVariables.lsp and have it loaded when you need.

deegeecees

  • Guest
Re: global variable
« Reply #7 on: March 04, 2008, 12:44:31 PM »
You could possibly use an ASCII text file for each drawing and read/write to it with certain information, save it with an extension of lets say, .cad, and hide the file type from users (if you need to).

But I'm the coding equivalent of a KART racer in a NASCAR world.

gile

  • Water Moccasin
  • Posts: 2233
  • Marseille, France
Re: global variable
« Reply #8 on: March 04, 2008, 12:58:53 PM »
Hi,

You can also use the setenv and getenv functions to write in the registry.

(setenv "MyData" "1")
works the same as:
(vl-registry-Write "HKEY_CURRENT_USER\\software\\Autodesk\\AutoCAD\\R17.0\\ACAD-5001:40C\\FixedProfile\\General" "MyData" "1")

and
(getenv "MyData")
as:
(vl-registry-read "HKEY_CURRENT_USER\\software\\Autodesk\\AutoCAD\\R17.0\\ACAD-5001:40C\\FixedProfile\\General" "MyData")
Speaking English as a French Frog

deegeecees

  • Guest
Re: global variable
« Reply #9 on: March 04, 2008, 01:09:36 PM »
Haaaayyyy! That's kinda nifty!

...adding to my code snippets file...

wizman

  • Bull Frog
  • Posts: 228
Re: global variable
« Reply #10 on: March 04, 2008, 01:36:21 PM »
thanks guys for your reply, my intent in saving a variable is to know which menu was last loaded so that it would be checked already once  i open acad because it defaults back to all unchecked.
writing a temporary file also is another option but what if in the middle of running a menu swapping an error occurs, which usually happens because of menu un-synchronization due to cuiload function.


so far i got this:
$(if,$(and,$(getvar,useri1),1),!.)&mypulldown

useri1 is user sysvar but only in current drawing, if only there is a way to have useri1 variable be saved globally or in registry...

giles suggestion is interesting, but not sure whether getenv runs in diesel, i let you guys know if its ok on my side,
ill continue working with this one tomorrow, many thanks guys. :-)

GDF

  • Water Moccasin
  • Posts: 2000
Re: global variable
« Reply #11 on: March 04, 2008, 02:32:25 PM »
Thanks gary, ill have a look at those functions in the developer help.

Here is how I use it in our office (all of our global vars), see inclosed text file.
I know I use too many...but it's fun playing with them.

For a stand alone example, check out Lumber.lsp with Lumber.dcl routine by Chris Ridder 08/03
Why is there never enough time to do it right, but always enough time to do it over?
BricsCAD 2019x64 Windows 10x64

wizman

  • Bull Frog
  • Posts: 228
Re: global variable
« Reply #12 on: March 05, 2008, 12:29:07 PM »
thanks gary for posting your sample code, i learned from that how to manipulate those registry functions,
i was also able to make it through setenv and getenv from gile, thanks to all who responded, great help guys!keep up.