Andrew1979 发表于 2022-7-5 20:01:02

Simple LISP, big problem

I have been using a lisp routine with no issues at all on many computers and many different drawings. Until recently. I have this one drawing that crashes when the LISP routine is run. This crash may happen or may not.....most of the time it does but at different points.
This happens on every computer I have used it on....which is 5 different computers using different versions of AutoCAd and windows.....so I am certain there is something seriously worng with the file
 
Basically this routine just scrolls through paper space layouts and exports them to a drawing file. This works fine on every other drawing I have ever used.
 
Also, exporting paper space layouts to the seperate drawings manually works no problem at all. So basically I think this drawing has problems already, and something in the routine triggers it.
 
I have put the routine below. Any ideas what could be causing a total AutoCAD crash when this routine is run? and only on this one drawing?
 

(defun C:p2m ()(getOldVar)(process)(reset)    )(defun process ()(setq filepath (getvar "dwgprefix")) (setq exported "Exported")(setq fulldir (strcat filepath exported))   (vl-mkdir fulldir)(foreach lo (layoutlist)(progn(setvar "CTAB" lo)(setq dwgfn (strcat fulldir "\\" lo))(command "exportlayout" dwgfn));command);progn );end defun (defun getOldVar ()(setq oldcmdecho    (getvar "cmdecho"))(setq oldfiledia    (getvar "filedia"))(command "cmdecho" "0")(setvar "FILEDIA" 0)   (command "undo" "mark")(command "undo" "begin") (setq temperr *error*)(setq *error* CCerror)       ) (defun CCerror (CCerrmsg)(setq    *error* temperror)(setvar "FILEDIA"oldfiledia)(setvar "cmdecho" oldcmdecho)(command "undo" "back")    (command "undo" "end")(command "undo" "mark")(prompt "\nCommand Cancelled°... "))(defun reset ()(command "undo" "back")    (command "undo" "end")(command "undo" "mark")(setvar "FILEDIA"oldfiledia)(setvar "cmdecho" oldcmdecho)(prompt "\nExport Complete... "))

ReMark 发表于 2022-7-5 20:13:53

Why post the lisp routine if you have already determined the problem is with the drawing you are using it in?Makes no sense.
 
Attach a copy of the drawing to your next post.

Andrew1979 发表于 2022-7-5 20:24:53

well I posted the routine as I thought there is obviously something in it causing a crash. I mean why would exporting the layouts manually work but using the LISP routine causes a crash? Although I feel there must be something wrong with the drawing too, its obvious this is something triggered by the LISP routine so thought it was worthputting up for review.
 
Unfortunately I cannot post the drawing due to privacy/legal etc, all that stuff.

ReMark 发表于 2022-7-5 20:38:17

I guess I misread this.....
"I have been using a lisp routine with no issues at all on many computersand many different drawings. Until recently. I have this one drawingthat crashes when the LISP routine is run."
 
It's difficult to diagnose a problem when you do not have access to the drawing that the problem is evident in don't you agree?

SLW210 发表于 2022-7-5 20:43:39

All that is needed in the .dwg is enough so that the drawing still crashes when the LISP is run.
 
You might actually find your problem by removing one thing at a time until it stops crashing.

Commandobill 发表于 2022-7-5 20:51:44

Andrew,
 
I would compare the DWG you are using it on to other drawings as far as the file size. Looking at the LISP alone, I don't see anything there that would cause the crash other than the fact that exporting layouts takes up some ram. There may be something in the DWG that is making the file much larger. In that case I would take the usual steps to decrease the file size (dxfout/dxfin, purge, audit, etc) and see if you still have the issue.

BrianTFC 发表于 2022-7-5 21:01:46

I ran your lisp on a drawing with tabs and it worked just, you need to run an audit on you drawing...
页: [1]
查看完整版本: Simple LISP, big problem