How to prevent AutoCAD from echo commands from AutoLisp?

How to prevent AutoCAD from echo commands from AutoLisp?

hisham_tannous
Community Visitor Community Visitor
527 Views
2 Replies
Message 1 of 3

How to prevent AutoCAD from echo commands from AutoLisp?

hisham_tannous
Community Visitor
Community Visitor

Hi guys, I have a Python program, and an AutoLISP code. I want to prevent users from loading the *.lsp code from AutoCAD using APPLOAD and instead force them to load it only from Python program. I searched a lot and I'm frustrated after a week of trial.

This is what I'm doing
mylisp.lsp:

 

(defun envvar ()
(if (/= (getenv "ENVVAR") "value")       ; compare it to value
    (progn
        (alert "This file can only be loaded from the Python script.")
        (exit))))

(envvr)
; rest of lisp code goes here such that if they load it without python it will fail otherwise it will succeed ​

 

my python code is:

 

    global acad
    acad = Autocad(create_if_not_exists=True)
    
    acad.doc.SendCommand('(setenv "ENVVAR" "value")\n')
    time.sleep(1)
    acad.doc.SendCommand('APPLOAD ') #loading the script after setting ENVVAR
# the rest of python code

 

everything works perfectly, the problem is, when I set the ENVVAR from python (line 4 above), it echoes everything in AutoCAD command line (shows the entire command with the value), I tried many things like adding a (princ) or some other things but I don't want the command to print the secret data for the ENVVAR when I set it.
How can I prevent it from echoing this. Or if you guys have a better idea for preventing people to load the lisp file without python code !


Thanks alot 

0 Likes
528 Views
2 Replies
Replies (2)
Message 2 of 3

paullimapa
Mentor
Mentor

What if you use python to update the registry where AutoCAD would see your environment variable?

This thread should give you an idea where they are stored


Paul Li
IT Specialist
@The Office
Apps & Publications | Video Demos
0 Likes
Message 3 of 3

ec-cad
Collaborator
Collaborator

(setvar "CMDECHO" 0)

 

ECCAD

0 Likes