How to prevent AutoCAD from echo commands from AutoLisp?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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