Author Topic: Acad 2012 sometimes delays princ from a loop  (Read 2588 times)

0 Members and 1 Guest are viewing this topic.

mkweaver

  • Bull Frog
  • Posts: 352
Acad 2012 sometimes delays princ from a loop
« on: November 17, 2011, 11:48:07 AM »
Is anyone else seeing this?

I used to be able to use princ in a loop to let the user know that autocad was thinking.  Now it seems that if the loop takes too long then the output from princ is delayed until the lisp routine is complete.

For example, the following routine will show the princ output for the first while loop, then the second, but the third doesn't show until the routine is complete:

Code: [Select]
  (setq indx 0)
  (while (< (setq indx (1+ indx)) 10000)
    (if (= 0 (rem (* 1000 indx) 1000))
      (princ "X")
      )
    )

Is there any way to force the output to show up when the princ is executed?

What is the time limit when this delay is triggered?

How about some other way to let the user know that it's not time to kill the Acad process?

Mike

Lee Mac

  • Seagull
  • Posts: 12913
  • London, England
Re: Acad 2012 sometimes delays princ from a loop
« Reply #1 on: November 17, 2011, 12:07:42 PM »
This looks to be the same as is described in this thread.

In the past I've found an extra (princ) after the first (princ) call will force the command-line to update, although, if ACAD is being rendered non-responsive, I doubt this will help.

KewlToyZ

  • Guest
Re: Acad 2012 sometimes delays princ from a loop
« Reply #2 on: November 17, 2011, 12:09:40 PM »
Just out of curiosity, are you using the drawing tabs add on?
I noticed the delay on large files or when I have multiple files open.
If I only have one or two files open the command line seems to spit out what I need.
I've been using the line by line counter from the swamp lately for a lot of things just to show work was occurring.
Example:
Code: [Select]
; Change all hatches, solids, & fills to color 250 and send to back of drawing order
; Special thanks to TheSwamp crew:  CAB, T.Willey, ronjonp, GDF, & Lee Mac for their guidance, code, and suggestions.
; http://www.theswamp.org/index.php?topic=20391.0;all

(defun c:HATCH250()
;===========================================================================Turn off command line responses
(command "CMDECHO" 0);DO NOT CHANGE THIS LINE
;===========================================================================

(if (setq AllHatch (ssget "_X" '((0 . "HATCH")))) ; begin if
(progn
(setq order "Back") ;sets opt to "_b" (back)
(setq NumHatch (sslength AllHatch))
(setq Count 0)
(princ "\n   Total Hatches found : ")
(princ NumHatch)

  (repeat NumHatch ;;this cycles number of items
    (setq Ename (ssname AllHatch Count))  ;;get entity name
    (setq Edata (entget Ename))
    (setq HatchLyr (cdr (assoc 8 Edata))) ;;get hatch layer name
    (prompt "\n   Hatch found!! Please Wait......") ;amusement
    ;(command "layer" "c" "250" HatchLyr "") ;;change hatch layer color to 250
    (command "chprop" AllHatch "" "COLOR" "250" "")
    (command "_.draworder" AllHatch "" order)
    (setq Count (+ 1 Count))
(princ "\n   Count = [ ")
(princ Count)
(princ " ] sorting next of total: ")
(princ NumHatch)
    (command "clayer" "0")   
  )
  (prompt "\n   Hatch Draw Order sent to back & Layer Made Color 250 !!!")
 ) ;then
 (prompt "\n   No Hatch objects found!") ;else
 )
(princ)

;===========================================================================

(if (setq AllFILL (ssget "_X" '((0 . "FILL")))) ; begin if
(progn
(setq order "Back") ;sets opt to "_b" (back)
(setq NumFILL (sslength AllFILL))
(setq Count 0)
(princ "\n   Total Fills found : ")
(princ NumFILL)

  (repeat NumFILL ;;this cycles number of items
    (setq Ename (ssname AllFILL Count))  ;;get entity name
    (setq Edata (entget Ename))
    (setq FILLLyr (cdr (assoc 8 Edata))) ;;get FILL layer name
    (prompt "\n   FILL found!! Please Wait......") ;amusement
    ;(command "layer" "c" "250" FILLLyr "") ;;change FILL layer color to 250
    (command "chprop" AllFILL "" "COLOR" "250" "")
    (command "_.draworder" AllFILL "" order)
(princ "\n   Count = [ ")
    (princ Count)
(princ " ] sorting next of total: ")
(princ NumFILL)
    (command "clayer" "0")   
  )
  (prompt "\n   FILL Draw Order sent to back & Layer Made Color 250 !!!")
 ) ;then
 (prompt "\n   No FILL objects found!") ;else
 )
(princ)
;===========================================================================

(if (setq AllSOLID (ssget "_X" '((0 . "SOLID")))) ; begin if
(progn
(setq order "Back") ;sets opt to "_b" (back)
(setq NumSOLID (sslength AllSOLID))
(setq Count 0)
(princ "\n   Total Solids found : ")
(princ NumSOLID)

  (repeat NumSOLID ;;this cycles number of items
    (setq Ename (ssname AllSOLID Count))  ;;get entity name
    (setq Edata (entget Ename))
    (setq SOLIDLyr (cdr (assoc 8 Edata))) ;;get SOLID layer name
    (prompt "\n   SOLID found!! Please Wait......") ;amusement
    ;(command "layer" "c" "250" SOLIDLyr "") ;;change SOLID layer color to 250
    (command "chprop" AllSOLID "" "COLOR" "250" "")
    (command "_.draworder" AllSOLID "" order)
    (setq Count (+ 1 Count))
(princ "\n   Count = [ ")
(princ Count)
(princ " ] sorting next of total: ")
(princ NumSOLID)
    (command "clayer" "0")   
  )
  (prompt "\n   SOLID Draw Order sent to back & Layer Made Color 250 !!!")
 ) ;then
 (prompt "\n   No SOLID objects found!\n") ;else
 )
(princ)
;===========================================================================Turn on command line responses
(setvar "CMDECHO" 1); DO NOT CHANGE THIS LINE
;===========================================================================

;===========================================================================
)

mkweaver

  • Bull Frog
  • Posts: 352
Re: Acad 2012 sometimes delays princ from a loop
« Reply #3 on: November 17, 2011, 01:29:35 PM »
Okay.  Thanks for the help - at least I can quit looking for a solution.

Mike

ribarm

  • Gator
  • Posts: 3265
  • Marko Ribar, architect
Re: Acad 2012 sometimes delays princ from a loop
« Reply #4 on: November 17, 2011, 02:07:59 PM »
Try this... This works fine on my CAD...

Code: [Select]
(defun c:process ( / indx )
  (setq indx 0)
  (textpage)
  (getstring "\nPress ENTER")
  (while (<= (setq indx (1+ indx)) 1000000)
    (if (= 0 (rem (* 10 indx) 1000000))
     (progn
      (prompt "X")
      (princ)
     )
    )
  )
(princ)
)
Marko Ribar, d.i.a. (graduated engineer of architecture)

:)

M.R. on Youtube

mkweaver

  • Bull Frog
  • Posts: 352
Re: Acad 2012 sometimes delays princ from a loop
« Reply #5 on: November 17, 2011, 03:14:25 PM »
Marko,
That seems to work, thanks!

Mike