long lisp processing data, autocad hangs. progress bar is no good?

long lisp processing data, autocad hangs. progress bar is no good?

zasanil
Advocate Advocate
1,160 Views
5 Replies
Message 1 of 6

long lisp processing data, autocad hangs. progress bar is no good?

zasanil
Advocate
Advocate

Greetings,

I have a few lisp routines that I am running on a drawing, and autocad seems to hang with the busy icon going during a long processing part of it. The command line bar stops responding during this time and the acet-ui-progress progress bar I have showing in the message area also hangs at a certain precent (30-40%). When the lisp is done processing the data, every thing then jumps to being finished.

My understanding is that it's somthing to do with autocad loosing communication with the message area and not being multi-threading frendly? Is there a progress bara that I can use that actually updates correctly even if autocad hangs? Or is there another work-around that I can do to still show progress of my running routine?

Dan Nicholson C.I.D.
PCB Design Engineer
0 Likes
1,161 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
Have run into this problem for years. My work around is to write to the coordinate display area using (grtext-2 "") and then (grtext -1 "Processing....") to at least show something is happening.
0 Likes
Message 3 of 6

Anonymous
Not applicable

Hello zasanil,

 

Progress bars are always a pain to deal with specially when u want the exact data and time processing.

 

I just use a mockup progress bar totally running separate from my program just to show and tell my users to standby.

So even though the programs seems to be doing nothing my progress bar is still running.

0 Likes
Message 4 of 6

dgorsman
Consultant
Consultant

Might be time to look into loop optimization - eliminate redundant operations, sort the data so loops can exit early, reduce in-loop calculations, etc.  It may be better to break the one long loop into a series of shorter loops.

----------------------------------
If you are going to fly by the seat of your pants, expect friction burns.
"I don't know" is the beginning of knowledge, not the end.


0 Likes
Message 5 of 6

lucas_zastrow_1994
Explorer
Explorer

I know I'm almost 10 years late, but since I couldn't find the answer anywhere on the internet, here it is...

 


From C#:

 

using System.Windows.Forms;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.DatabaseServices;

[assembly: CommandClass(typeof(AutocadUtils.Functions))]
namespace AutocadUtils
{
    public class Functions
    {
        /// Use this lisp function in large list iterations, to avoid freezing.
        [LispFunction("DoEvents")]
        public object DoEvents(ResultBuffer arg)
        {
            Application.DoEvents();
            return null;
        }
    }
}

 


Lisp usage example:

 

(defun c:RenameLayers( / layer layers)
	
	(tblnext "LAYER" T)
	
	(while (setq layer (tblnext "LAYER"))
		(DoEvents)
		(setq layers (append layers (list (cdr (assoc 2 layer)))))
	)
	
	(foreach layer layers
		(DoEvents)
		(command "._rename" "la" layer (strcat "_" layer))
	)
)

 


During Lisp execution, for some reason, Autocad will stop responding to Windows and, by using the Application.DoEvents method, all Windows messages currently in the message queue will be processed, which prevents the Autocad window from freezing.

I tested several lisp functions (core, express, ActiveX and DOSlib), in the hope that at least one of them could do something similar, but I didn't find any.

Message 6 of 6

Sea-Haven
Mentor
Mentor

I use a simple (princ ".") so a row of dots appear seems to work for any number of loops, so if you use the percentage method like the acet-progress should show something happening as a single row. 

 

Just a side comment a task took 35 minutes using "command" mostly, redid with with VL and entmakes takes 2 minutes now, so internal speed enhancement can be a way to go. As already suggested looking at internal coding can help.

0 Likes