LISP Prob1 - Opening a file

LISP Prob1 - Opening a file

LispResearch
Enthusiast Enthusiast
628 Views
4 Replies
Message 1 of 5

LISP Prob1 - Opening a file

LispResearch
Enthusiast
Enthusiast

Greetings dear AutoCAD gurus,

 

My goal is to make a LISP script to open a file with dwt extension as if I would open it through "new" button. That means that it should open, and not with .dwt extension but with dwg extension. I want that for creating some buttons for different templates.

 

I tried to find answer on the forum, but I am sorry I could not - there are many examples that should work but they don't in my case.

 

These are some short scripts that I tried:

 

1. Using the Open command: (command "OPEN" "C:\ACAD_ISO_ANNO_B6_A3.dwt")

And the result is that Autocad says that dwt is unknown command like if it recognizes the period symbol inside quotation marks for system symbol.

 

Here is a set of command line strings I get:

=== START ===

Command: (command "OPEN" "C:\ACAD_ISO_ANNO_B6_A3.dwt")
OPEN
Command: C:ACAD_ISO_ANNO_B6_A3.dwt Unknown command "DWT". Press F1 for help.
Command: nil

=== END ===

 

2. Using vla function: (vla-open (vla-get-documents (vlax-get-acad-object)) "C:/ACAD_ISO_ANNO_B6_A3.dwt")

The result is that it opens the file but as an original template with dwt extension. Whereas I want it to be something like Drawing1.dwg.

 

My question or request is if it is possible to solve on both and how, what am I doing wrong?

Signature:
Interested in Lisp
0 Likes
Accepted solutions (1)
629 Views
4 Replies
Replies (4)
Message 2 of 5

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

not read all of your post, but the first guess with the LISP-statement: To use path-separator in LISP you need either / or \\ (slash or double backslash).

So change the code to:

(command "OPEN" "C:\\ACAD_ISO_ANNO_B6_A3.dwt")
or
(command "OPEN" "C:/ACAD_ISO_ANNO_B6_A3.dwt")

And let us know if that work's for you.

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 3 of 5

LispResearch
Enthusiast
Enthusiast

To be true I tried these variations before, but forgot to write, anyway here are the results in command line:

 

A1. when I use (command "OPEN" "C:\\ACAD_ISO_ANNO_B6_A3.dwt"):

=== 

Command: (command "OPEN" "C:\\ACAD_ISO_ANNO_B6_A3.dwt")
OPEN
Command: C:\ACAD_ISO_ANNO_B6_A3.dwt Unknown command "DWT". Press F1 for help.
Command: nil

===

 

A2. when I use  (command "OPEN" "C:/ACAD_ISO_ANNO_B6_A3.dwt")

===

Command: (command "OPEN" "C:/ACAD_ISO_ANNO_B6_A3.dwt")
OPEN
Command: C:/ACAD_ISO_ANNO_B6_A3.dwt Unknown command "DWT". Press F1 for help.
Command: nil

===

 

An additional thought from my mind: Can the switches or variables be the problem? I was editing some switshes to customize and optimize my AutoCAD but I use it for about 2 years from installation and do not remember what I changed.

Signature:
Interested in Lisp
0 Likes
Message 4 of 5

Alfred.NESWADBA
Consultant
Consultant
Accepted solution

Hi,

 

tried it now, seems like (command "_OPEN" ... does not work with extension DWT.

Maybe >>>that blog<<< shows you how to create new drawings based on a specific DWT.

 

Good luck, - alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
Message 5 of 5

LispResearch
Enthusiast
Enthusiast

Yes it does exactly what I want. Thank you Alfred.

 

Sadly, that could not find a solution to "open" command usage. Sometimes it seems that it is simple I just don't see some quotation mark r bracket or something should be added but probably not in this case.

 

The main problem is solved.

Signature:
Interested in Lisp
0 Likes