PDA

View Full Version : Closing a drawing



JasonSelf
2004-08-05, 04:45 PM
I have written a lisp routine that basically writes a script that takes care batch printing in our office. In the routine I have been using two lines qsave, and then close because I have not been able to find a way to close a drawing witout saving first (I get the prompt do you want to save) I set cmddia to 0 and tried to do a (command "close" "yes") but it seems to let me do that. Does anybody know of a way to disable the warning "do you really want to abandon all changes" or to get a script or lisp routine to handle this?

Thank you.
Jason Self

RobertB
2004-08-05, 05:05 PM
._Close
(if (> (getvar "DbMod") 0) (command "_Yes"))

mjfarrell
2004-08-05, 05:39 PM
Would setting EXPERT sysvar to 5 have the same effect?

RobertB
2004-08-05, 05:53 PM
Would setting EXPERT sysvar to 5 have the same effect?

No.

Command: expert
Enter new value for EXPERT <0>: 5

Command: l LINE Specify first point:
Specify next point or [Undo]:
Specify next point or [Undo]:

Command: scr
SCRIPT
Command: ._Zoom
Specify corner of window, enter a scale factor (nX or nXP), or
[All/Center/Dynamic/Extents/Previous/Scale/Window/Object] <real time>: _extents
Command: ._Close
Command: Really want to discard all changes to drawing? <N> *Cancel*

CADmium
2004-08-17, 08:18 PM
look here:



(defun c:fastquit ()
(vl-load-com)
(vlax-for doc(vla-get-documents(vlax-get-acad-object))
(vl-catch-all-apply
'vla-close
(list doc)
)
)
(command "vbastmt" "activedocument.close false")
)


all drawings are closed without saving!

and, if it is only one drawing :
only : (command "vbastmt" "activedocument.close false")

bbapties
2004-08-18, 12:36 PM
Hey thomas.krueger,

I loaded and tested that and it does close all with out asking the "are you sure....", but it did save all the drawings. :(

I made sure I zoomed extents in each drawing and saved and then pan to the side on each drawing to double check and sure enough when I open the drawings back up they are panned to the side.....

Do I have to change some sort of variable? :?

Thanks

RobertB
2004-08-18, 05:16 PM
No, his code is bad. See my (untested) change:


(defun c:fastquit ()
(vl-load-com)
(vlax-for doc (vla-get-documents (vlax-get-acad-object))
(vl-catch-all-apply
'vla-close
(list doc :vlax-False)))
(command "vbastmt" "activedocument.close false"))

bbapties
2004-08-18, 05:34 PM
thanks rob, that's perfect:D

CADmium
2004-08-18, 07:26 PM
@Bbapties
Understanding problem.Sorry! I must become better in English!

RobertB
2004-08-18, 08:26 PM
Understanding problem. Sorry! I must become better in English!

Your English was good enough. It was just your code that needed a little work. :mrgreen:

bbapties
2004-08-18, 08:30 PM
It may have lost a little in translation?? But I appreciate the effort and time :beer:

JasonSelf
2004-08-23, 02:22 PM
Thanks for all the replys, I just now got a chance to read them.

cwade.109269
2009-05-07, 08:50 PM
Ok, I have been searching online for an answer, how do I close a drawing without using the vbastmt?

I am trying to eliminate the need for visual basic in my code, since it no longer ships with 2010 and this is actually the last piece that I need.

Please note that using the (command "._close") causes errors when my lisp routine opens the next drawing for some reason.

What I have is:
(vla-close (vla-get-documents (vlax-get-acad-object)) :vlax-true)

But for some reason, this doesn't seem to be working.

RobertB
2009-05-07, 11:30 PM
Ok, I have been searching online for an answer, how do I close a drawing without using the vbastmt?

I am trying to eliminate the need for visual basic in my code, since it no longer ships with 2010 and this is actually the last piece that I need.

Please note that using the (command "._close") causes errors when my lisp routine opens the next drawing for some reason.

What I have is:
(vla-close (vla-get-documents (vlax-get-acad-object)) :vlax-true)

But for some reason, this doesn't seem to be working.Hint: You haven't gotten to the document yet with that posted code. All you grabbed was the collection of documents.

cwade.109269
2009-05-07, 11:34 PM
I see, thank you for that much information, now the question I have is how do I get to the document? I'm trying here, but I don't know much about these vla- functions yet.

All that I need to do is find a way to close the currently active drawing, any and all help is appreciated, unfortunately these vla functions don't seem to be documented too well.

cwade.109269
2009-05-08, 05:18 PM
Ok, I have been trying to figure this out, I still can't seem to get it to close the currently active drawing.

Basically my LISP routine uses ObjectDCL and runs the script when the drawing is opened, then when that drawing is closed and the original one is activated, it opens the next drawing.

I have it opening the drawings just fine, but it will not close the drawings, unless I uses (command "._close"), then it will close the drawing, but it causes AutoCad to have a fatal error and AutoCAD has to be closed with task manager at that point.

Please, if anyone can help me figure out how to close the currently active drawing, I would greatly appreciate it.

Also, obviously I can't use the variable that I used to open the file, as it is a new file and that variable doesn't exist in it.

Opie
2009-05-08, 05:49 PM
Looking at the Express Tools Revert Drawing Tool [c:revert] I see that it also uses the VBASTMT command to do the work.

Autodesk is supplying a seperate download for the VBA Enabler (http://images.autodesk.com/adsk/files/autocad2010vbaenabler32.exe) for 2010. You may have to add it to your other workstations.

cwade.109269
2009-05-08, 06:07 PM
This is the only routine that we are using that requires VBA, which means I am trying to find a way around having to use it. By not loading VBA AutoCAD runs much faster from what I have been seeing, I have loaded it on one machine and saw an incredible slow down (this is on a 64 BIT machine, so that may actually be part of the reason why VBA causes such a slow down).

RobertB
2009-05-09, 04:24 AM
I have loaded it on one machine and saw an incredible slow down (this is on a 64 BIT machine, so that may actually be part of the reason why VBA causes such a slow down).Yes, 64-bit and VBA do not get along well, from a performance perspective.

However, please be aware that Visual LISP runs in a document context so it doesn't play so well when attempting to continue from one document to the next.

Might I suggest porting this one VBA app over to VB.NET?

cwade.109269
2009-05-11, 04:38 PM
Yes, 64-bit and VBA do not get along well, from a performance perspective.

However, please be aware that Visual LISP runs in a document context so it doesn't play so well when attempting to continue from one document to the next.

Might I suggest porting this one VBA app over to VB.NET?

But the rest of the App is in LISP, it is only the one line that is a VBA line and that is to open the files, I have found a workaround and that is to set SDI mode. I am using this with OpenDCL, so I am not actually continuing it from one drawing to the next, instead, it is actually restarting and reading the info it needs from my OPENDCL form to determine what needs to be done next.

Now I just have to put in an error handler to determine if more than one document is already open and ask the user to close all other files besides one and try again.

msretenovic
2009-05-12, 04:34 PM
HINT: To get the current drawing, take a look at the ActiveDocument property. ;)