Lisp expression for OPEN or INSERT

Lisp expression for OPEN or INSERT

tmccar
Advisor Advisor
814 Views
5 Replies
Message 1 of 6

Lisp expression for OPEN or INSERT

tmccar
Advisor
Advisor

If I enter Lisp expressions on the command line, they get evaluated ok, but not where a filename is required (e.g. for OPEN or INSERT). I get "Invalid file name" when I try to use a "strcat" expression. Is there a way around this?

0 Likes
815 Views
5 Replies
Replies (5)
Message 2 of 6

hmsilva
Mentor
Mentor

@tmccar wrote:

If I enter Lisp expressions on the command line, they get evaluated ok, but not where a filename is required (e.g. for OPEN or INSERT). I get "Invalid file name" when I try to use a "strcat" expression. Is there a way around this?


Hi tmccar,

 

your explanation is vague, could you please show an specific example.

 

Using a path in 'LISP', you'll have to enter two backslashes "\\" or a single slash "/"

i.e.

(strcat "c:\\test\\test\\" "test.dwg")
;; or
(strcat "c:/test/test/" "test.dwg")

 

Hope this helps,
Henrique

EESignature

0 Likes
Message 3 of 6

tmccar
Advisor
Advisor

For instance, I can enter this expression at the command line:

 

(setenv "filedir" "C:/dwgs/")

and then

(strcat (getenv "filedir") "Folder1/cover1.dwg")

and it will corrrectly evaluate the full path so:

C:/dwgsFolder1/cover1.dwg

 

But I would like to enter the expression (strcat (getenv "filedir") "Folder1/cover1.dwg") in response to the Open or Insert command.

 

 

0 Likes
Message 4 of 6

hmsilva
Mentor
Mentor

@tmccar wrote:

 

But I would like to enter the expression (strcat (getenv "filedir") "Folder1/cover1.dwg") in response to the Open or Insert command.

 


???

 

Try

(defun c:demo (/ file)
  (setenv "filedir" "C:/dwgs/")
  (setq file (strcat (getenv "filedir") "Folder1/cover1.dwg"))
  (if (findfile file)
    (command "_.-insert" file "_S" 1 "_R" 0 '(0.0 0.0 0.0))
    (prompt (strcat "\n" file " was not found! "))
  )
  (princ)
)

 

Hope this helps,
Henrique

EESignature

Message 5 of 6

tmccar
Advisor
Advisor

Thanks Henrique - I had forgotten to set TEXTEVAL to 1

0 Likes
Message 6 of 6

hmsilva
Mentor
Mentor

You're welcome, tmccar.
Glad you got it sorted!

Henrique

EESignature

0 Likes