Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How do I open a drawing at AutoCAD startup?

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
248 Views, 2 Replies

How do I open a drawing at AutoCAD startup?

Hello,

In the AcadDoc I check to see if the current profile is a special one that I
created. If it is, I show the user a list of filenames (just a bunch of
strings in a dialog box) and have them select the one to be opened.

The problem is that my OpenDwgFile function crashes AutoCAD unless I add
another (command pause) line before the vla call. Without it, the error
message is: "Bad argument type: VLA-OBJECT nil".

It works with the extra pause, but the original drawing "Drawing1.dwg"
remains busy for the remainder of the session. Also, if I start AutoCAD in
a different profile and then in my special one, it makes me click on the
screen before it opens the new drawing (responding to the extra pause).

Any ideas on what's going on with the pauses and AutoCAD? Here's my
OpenDwgFile function:

(defun OpenDwgFile (dwgFile / acad acadDoc openDoc)
(vl-load-com)
(setq nameAndPath (strcat dwgFile ".dwg"))

(if (setq fullPath (findfile nameAndPath))
(progn
(while (= (logand (getvar "cmdactive") 1) 1)
(command pause)
)
;(command pause)
(vla-activate (vla-open (vla-get-documents (vlax-get-acad-object))
fullPath :VLAX-TRUE))
)
(progn
(alert "Cannot find structure drawing!")
)
)
)

Thanks so much!

-Carlos
2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: Anonymous

Add it to acad.mnl.


"Carlos" wrote in message
news:4954048@discussion.autodesk.com...
Hello,

In the AcadDoc I check to see if the current profile is a special one that I
created. If it is, I show the user a list of filenames (just a bunch of
strings in a dialog box) and have them select the one to be opened.

The problem is that my OpenDwgFile function crashes AutoCAD unless I add
another (command pause) line before the vla call. Without it, the error
message is: "Bad argument type: VLA-OBJECT nil".

It works with the extra pause, but the original drawing "Drawing1.dwg"
remains busy for the remainder of the session. Also, if I start AutoCAD in
a different profile and then in my special one, it makes me click on the
screen before it opens the new drawing (responding to the extra pause).

Any ideas on what's going on with the pauses and AutoCAD? Here's my
OpenDwgFile function:

(defun OpenDwgFile (dwgFile / acad acadDoc openDoc)
(vl-load-com)
(setq nameAndPath (strcat dwgFile ".dwg"))

(if (setq fullPath (findfile nameAndPath))
(progn
(while (= (logand (getvar "cmdactive") 1) 1)
(command pause)
)
;(command pause)
(vla-activate (vla-open (vla-get-documents (vlax-get-acad-object))
fullPath :VLAX-TRUE))
)
(progn
(alert "Cannot find structure drawing!")
)
)
)

Thanks so much!

-Carlos
Message 3 of 3
Anonymous
in reply to: Anonymous

Hi Rudy,

Thanks for pointing that file out. There seem to be lots of threads out
there with ideas related to acad.mnl.

I'll check them out.

Thanks,
Carlos




"Rudy Tovar" wrote in message
news:4954108@discussion.autodesk.com...
Add it to acad.mnl.


"Carlos" wrote in message
news:4954048@discussion.autodesk.com...
Hello,

In the AcadDoc I check to see if the current profile is a special one that I
created. If it is, I show the user a list of filenames (just a bunch of
strings in a dialog box) and have them select the one to be opened.

The problem is that my OpenDwgFile function crashes AutoCAD unless I add
another (command pause) line before the vla call. Without it, the error
message is: "Bad argument type: VLA-OBJECT nil".

It works with the extra pause, but the original drawing "Drawing1.dwg"
remains busy for the remainder of the session. Also, if I start AutoCAD in
a different profile and then in my special one, it makes me click on the
screen before it opens the new drawing (responding to the extra pause).

Any ideas on what's going on with the pauses and AutoCAD? Here's my
OpenDwgFile function:

(defun OpenDwgFile (dwgFile / acad acadDoc openDoc)
(vl-load-com)
(setq nameAndPath (strcat dwgFile ".dwg"))

(if (setq fullPath (findfile nameAndPath))
(progn
(while (= (logand (getvar "cmdactive") 1) 1)
(command pause)
)
;(command pause)
(vla-activate (vla-open (vla-get-documents (vlax-get-acad-object))
fullPath :VLAX-TRUE))
)
(progn
(alert "Cannot find structure drawing!")
)
)
)

Thanks so much!

-Carlos

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost