Preventing from crashing LISP routine that loads/calls many other LISPS

Preventing from crashing LISP routine that loads/calls many other LISPS

Anonymous
Not applicable
1,005 Views
4 Replies
Message 1 of 5

Preventing from crashing LISP routine that loads/calls many other LISPS

Anonymous
Not applicable

Hello,

 

I've collected a huge sequence of LISPS here on forum and over the Internet, testing them a LOT for many situations (all the best I've found and that was working well 95% of time) to get any .dwg file as purest and cleanest as possible by loading the following sequence of LISPs, in sequence:

 

1.Delete all layouts;

2.Sets Color (setvar "cecolor"), Linetype (setvar "celtype") and Lineweight (setvar "celtype") to "ByLayer";

3.Sets "Allow exploding for all blocks";

4.Burstall blocks in the drawing;

5.Delete remaining blocks after the super burst upgraded LISP;

6.Explode all dimension and leader styles, converting them to basic AutoCAD entities;

7.Steal "Standard" styles from basic acad.dwt (isso) template and set all them current for dimensions, textstyles, leader styles and so on;

8.Delete all constraints of the drawing;

9.Converts any Attribute back to Normal Texts;

10.Converts "Mtext" to normal "Dtext" and bring all them to front;

11.Converts 2D solids to hatches;

12.Converts splines to polylines;

13.Converts elipses to polylines;

14.Convert region to polylines;

15.Erase all wipeouts;

16.Erase all ACADpoints;

17.Gets the colour from entities (first) or from the layer where the object is inserted (second) and applies to the the object properties;

18.Gets the linetype from entities (first) or from the layer where the object is inserted (second) and applies to the the object properties;

19.Sets all linetypescales to 1.0;

20.Converts 3D to 2D polylines;

 

Sometimes, for any reason, when one of those LISPS crashes/fails or was not able to be executed, the aftwards LISPS are not being loaded/executed aswell. Is there any way to prevent this from happening? I mean, is there any way IF some of those loaded LISP has crashed, the aftwards LISPS still are able to run properly, ignoring possible errors?

 

The main LISP that loads all the other one is attached here and all the used LISPS are attached aswell. My intention is to introduce something in the loading code (like a condition) to get all LISPS running and loading, in this sequence, one after other, crashing or not. Is this possible?

 

Thanks in advance.

 

0 Likes
1,006 Views
4 Replies
Replies (4)
Message 2 of 5

cadffm
Consultant
Consultant
The trick is to write well working programs with a good error handling, so you "never" get an unexpected problem (without unhandled crash).
Sorry, only my opinion.

Tell us one of the files(or function) which crashes more often then another one,
so we can get this one as example for checking the content.

The load lsp is not the problem.

Sebastian

Message 3 of 5

Anonymous
Not applicable

@cadffm wrote:
The trick is to write well working programs with a good error handling, so you "never" get an unexpected problem (without unhandled crash).
Sorry, only my opinion.

Tell us one of the files(or function) which crashes more often then another one,
so we can get this one as example for checking the content.

The load lsp is not the problem.

 

I can't reproduce it all the time. It happens only 3-5% of time usage, but would not to be a problem to skip those LISPS that failed. My intention is just to know if there is some function that can be plugged to the "load" so it will skip the LISP that failed but still continues loading the aftwards LISPS. Just by how it is now, if some LISP crash or fails, all the next LISPS are not going to be loaded. With more time, maybe I can check which specific LISP is "bad coded" or crashing more often. But it will need lots of tests for many many diferente drawings, so the best solution now, was just to make the loads to work. Thanks for our suggestion anyway...

0 Likes
Message 4 of 5

scot-65
Advisor
Advisor
Tweak the LISP function LOAD:
(defun MyLoad ( a / )
(if (load a nil)
a
(alert (strcat "Utility \"" a "\" failed to load.")) ;something nil goes here.
);if
);MyLoad

Now, in the list of utilities:
(if (MyLoad "AA") (AA) (princ))
(if (MyLoad "BB") (BB) (princ))

For a program that is structured like this [can also be c:AA]:
(defun AA ( / )
(command ".QSAVE")
);AA

There is a difference between loading and executing a loaded routine.
The above example is protecting the loading aspect from crashing.
I will assume this is what the issue is?

One can also try 'OR' so as attempting to block the error from stopping
the rest of the utility [untested]? Otherwise inject *error* in each file.
(or (load AA nil))
(or (load BB nil))

???

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

0 Likes
Message 5 of 5

doaiena
Collaborator
Collaborator

Execution of a routine should begin, only after all of your routines have been loaded. You should make sure to structure your lisp files in such a way. Try defining your functions and executing them like this, and tell me if it works.

 

(defun test1 ()
(alert "test1 successfully ran.")
)

(defun test2 ()
(alert "test2 successfully ran.")
)

(defun test3 ()
(alert "test3 successfully ran." cause error here)
)

(defun test4 ()
(alert "test4 successfully ran.")
)

(foreach fun (list "(test1)" "(test2)" "(test3)" "(test4)")
(if (vl-catch-all-apply 'eval (list (read fun)))
(alert (strcat fun " failed to run!"))
);if
);foreach
0 Likes