Jump to content

Storing Lisp Variables across drawings.


Hardeight

Recommended Posts

Is there any way possible to store variables gathered through a lisp routine across more than one drawing?

I have written a User Verification routine to allow a user to login to a company database with the entered information. I was trying to do this to keep from having to prompt for user information everytime the database was accessed. Well I accomplished my goal, sort of.

Every time a new drawing is opened the user has to enter their info again when they want to access the DB.

I had a thought of storing the user ID and Password in a temporary text file on their hard drive and making a reactor that deleted the file every time they logged out or closed Autocad.

Is there an easier way to do this?

Link to comment
Share on other sites

Well, you could use the functions "setenv" and "getenv" - these will store the variables forever (until overwritten), but they do create a file in the registry, so be VERY carerful with them - use very specific names for the variables, so that you don't accidentally overwrite an important file.

See here for more info.

Link to comment
Share on other sites

Or you could just write to reg directly

 

(vl-registry-delete key)
(vl-registry-write key value)
(vl-registry-read key value)

 

Depending on your needs....

Link to comment
Share on other sites

Or you could also set it at startup in there acad.lsp

 

(setq this "that")

 

If the info is always the same... not sure what type of security you are in need of.

Link to comment
Share on other sites

Or you could also set it at startup in there acad.lsp

 

(setq this "that")

 

If the info is always the same... not sure what type of security you are in need of.

 

 

Nice idea with the startup, didn't think of that one Tim :thumbsup:

Link to comment
Share on other sites

One approach I take is to write the data to a ascii text in proper Autolisp format and then ( load ) the text file.

 

mydata.dat

 

(setq mydata '(
(X . 45)
(Y . "50")
(Z . (0 0 1))
))

(load "mydata.dat")

 

(load) is not limited to .lsp files. It defaults to .lsp extension but you can specify the file ext. It simple reads and evaluates the expressions.

 

I get the outputs from database reports, spreadsheets etc.

 

-David

Link to comment
Share on other sites

You could have a lot of fun with this topic.

 

Write a lisp that (re)writes a lisp.

Write to the drawing dict.

 

> Security.

You could encrypt (like XOR or even ROT13 -- simple, but i mean were not dealing with hackers or anything right?) the info in a plain text file. Besides that would be a good time to brush up on some fun encryption techniques.

Link to comment
Share on other sites

Wow, a lot of good ideas. I think I will try to use a combination of a few of these. The problem is, registry keys are indefinite right? So say a user closes autocad and goes home for the day. Their ID and Password are still in the registry. So if another user comes to their computer while they are gone, they can access the DB as the initial user.

Now, I am not all that familiar with reactors, but they are drawing based right?

I mean there is no way to have a reactor that clears the ID and Password out of the registry when the user closes autocad is there?

Link to comment
Share on other sites

One more

(vl-bb-ref 'symbol)

Returns the value of a variable from the blackboard namespace

 

(vl-bb-set 'symbol value)

Sets a variable in the blackboard namespace

 

(vl-propagate 'symbol)

Copies the value of a variable into all open document namespaces (and sets its

value in any subsequent drawings opened during the current AutoCAD session)

 

NOTE:

The blackboard variable is NOT updated with (setq varname

You must use (vl-bb-set 'varname NewValue) to modify it.

Link to comment
Share on other sites

You most likely have a copy of this lisp:)

;;;                                                                    ;
;;;  BLACKBOARD.lsp                                                    ;
;;;                                                                    ;
;;;  Copyright 1987, 1988, 1990, 1992, 1994, 1996, 1997, 1998, 1999    ;
;;;  by Autodesk, Inc. All Rights Reserved.                            ;
;;;                                                                    ;
;;;  You are hereby granted permission to use, copy and modify this    ;
;;;  software without charge, provided you do so exclusively for       ;
;;;  your own use or for use by others in your organization in the     ;
;;;  performance of their normal duties, and provided further that     ;
;;;  the above copyright notice appears in all copies and both that    ;
;;;  copyright notice and the limited warranty and restricted rights   ;
;;;  notice below appear in all supporting documentation.              ;
;;;                                                                    ;
;;;  Incorporation of any part of this software into other software,   ;
;;;  except when such incorporation is exclusively for your own use    ;
;;;  or for use by others in your organization in the performance of   ;
;;;  their normal duties, is prohibited without the prior written      ;
;;;  consent of Autodesk, Inc.                                         ;
;;;                                                                    ;
;;;  Copying, modification and distribution of this software or any    ;
;;;  part thereof in any form except as expressly provided herein is   ;
;;;  prohibited without the prior written consent of Autodesk, Inc.    ;
;;;                                                                    ;
;;;  AUTODESK PROVIDES THIS SOFTWARE "AS IS" AND WITH ALL FAULTS.      ;
;;;  AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF           ;
;;;  MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE.  AUTODESK,       ;
;;;  INC. DOES NOT WARRANT THAT THE OPERATION OF THE SOFTWARE          ;
;;;  WILL BE UNINTERRUPTED OR ERROR FREE.                              ;
;;;                                                                    ;
;;;  Restricted Rights for US Government Users.  This software         ;
;;;  and Documentation are provided with RESTRICTED RIGHTS for US      ;
;;;  US Government users.  Use, duplication, or disclosure by the      ;
;;;  Government is subject to restrictions as set forth in FAR         ;
;;;  12.212 (Commercial Computer Software-Restricted Rights) and       ;
;;;  DFAR 227.7202 (Rights in Technical Data and Computer Software),   ;
;;;  as applicable.  Manufacturer is Autodesk, Inc., 111 McInnis       ;
;;;  Parkway, San Rafael, California 94903.                            ;
;;;                                                                    ;
;;;
;;;
;;;	 Blackboard Sample
;;;
;;;
;;; Sample file supplied by: 	Perceptual Engineering Inc.
;;; web:			www.perceptual-eng.com
;;; Author:			Ralph Gimenez, Perceptual Engineering
;;;

Link to comment
Share on other sites

That blackboard worked just like I wanted.

Thanks CAB.

But all the other ideas have me thinking of new things to do and routines to write.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...