vernonlee 发表于 2022-7-5 19:02:07

 
Hi. The reason why i needed to "export" this values is I need to zoom to the same location for multiple drawings.

broncos15 发表于 2022-7-5 19:03:11

If your variables are global, they will be remembered between drawings. That way, you can zoom to the same location in as many drawings as you want.

BIGAL 发表于 2022-7-5 19:07:14

 
Having a problem with this do you know a secret ?
 
Global variables as per help is about running within one dwg not across multiples outside of say multiple defuns running in a session, the code by Lee hints at this by writing to file. Another alternative is to write say a string to the registery. vl-registry-writevl-registry-read

vernonlee 发表于 2022-7-5 19:12:43

 

 
Could you elobrate?

Lee Mac 发表于 2022-7-5 19:13:23

 
Not true I'm afraid: all symbols in AutoLISP are defined within the document namespace by default and therefore cannot be accessed outside of this namespace (unless you use vl-bb-set/vl-bb-ref to define symbols within the blackboard namespace which is a document-independent namespace and may therefore be accessed from any drawing).
 
Another alternative is to use vl-propagate to propagate a variable across all document namespaces.

BIGAL 发表于 2022-7-5 19:18:59

Thanks Lee

broncos15 发表于 2022-7-5 19:21:17

Lee, I thought setenv and getenv could be used to store variables in the registry (just need to be careful to not use the same variables and to not overuse it because it can bloat it). I haven't used them yet (haven't seen the need) but I remember reading about it when I was first learning lisp, did I misunderstand it? Also can't vl-propagate be used to "store" the variable so that it can be used for all open drawings in the current session?

Lee Mac 发表于 2022-7-5 19:26:08

 
Indeed, getenv & setenv can be used to read & write a string value (REG_SZ / REG_EXPAND_SZ) to a specific branch of the registry , however, these are not global variables as you stated in your post.
 
Writing such values to the registry is essentially the same as reading & writing data to a text file (which may in fact be a preferred option due to the ease of removal - this is the route I follow with the majority of my larger applications).
 
As noted in my post above, vl-propagate is also an option, however, this will cause a global variable to persist only during the current instance of the application.
页: 1 [2]
查看完整版本: LISP:Obtain Coordinates of a p