PDA

View Full Version : I want to Open a file


droak
2006-03-09, 12:50 PM
I'm afraid I've let my AutoLisp skills slip away, so please excuse what may be very simple questions.

1) I want to open a file.

2) I wrote this line:

(Command "Open" "T:Quoting-FilesEBTrunk-AssembliesSketches-For-Quoting.dwg" "")

3) It is reading "T:Quoting...dwg" as a command.

4) I tried typing it the following ways:

(Command "Open" ""T:Quoting-FilesEBTrunk-AssembliesSketches-For-Quoting.dwg"" "")

(Command "Open" "T:Quoting-FilesEBTrunk-AssembliesSketches-For-Quoting.dwg" "")

(Command "Open" "T:/Quoting-Files/EB/Trunk-Assemblies/Sketches-For-Quoting.dwg" "")

5) I got the same result.

6) By the way; I have set EXPERT to 3 to over ride the dialog box.

What is the convention/syntax for entering a file name that I to open

Respectfully,
Darrell

ccowgill
2006-03-09, 01:14 PM
(Command "Open" "y"
"T:/Quoting-Files/EB/Trunk-Assemblies/Sketches-For-Quoting.dwg" "")

you forgot to answer the prompt as to whether or not you want to discard all changes

droak
2006-03-09, 10:39 PM
"y" didn't work for me.

Here is the response from the AutoCAD Text Window:

Command: (Command "Open" "y"
"T:/Quoting-Files/EB/Trunk-Assemblies/Sketches-For-Quoting" "")
Open
Command: y Unknown command "Y"

If I type "OPEN" at the command line, I get the "Select File Dialog Box"; I get an option for "Yes" or "No"

Am I setting Expert to a setting other than what I should be? or should I be using another method to over-ride the dialog box?

Darrell

ccowgill
2006-03-09, 10:47 PM
Hopefully someone else has some suggestions, When I typed it in as shown below, it worked fine, I also included what the computer spit back:


Command: (Command "Open" "y" "c:/test.dwg" "")
Open Really want to discard all changes to drawing? <N> y
Enter name of drawing to open <MaverickEngineeringX5515X5515.DWG (file://MaverickEngineeringX5515X5515.DWG/)>: c:/test.dwg

T.Willey
2006-03-09, 10:56 PM
You can't use the open command within lisp to open a draiwng. You have to add the file to the document object of autocad, and go about it that way.

(defun MyOpen (FileName ReadOnly / )
; If readonly is not nil, then it will open the file as read-only.

(vl-load-com)
(vla-Open
(vla-get-Documents
(vlax-get-Acad-Object)
)
FileName
(if ReadOnly
:vlax-true
:vlax-false
)
)
)

peter
2006-03-10, 05:22 PM
Due to the fact that lisp is a document level programming language, it stops immediately after the new document opens. Which means the drawing you are leaving is in the middle of a command, unless you use a vba statement to open the new drawing.

This function will open a drawing. The syntax is: (openDrawing "c:/acad/mydrawing.dwg")


(defun OpenDrawing (strBlockName); blkname should include the file type
(if (findfile strBlockName)
(command "vbastmt" (strcat "AcadApplication.Documents.Open \"" strBlockName "\""))
(princ "\nFile not found: ")
)
(princ)
)

ccowgill
2006-03-10, 10:09 PM
that would obviously explain why it worked fine for me, I was just pasting it to the command line.