- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a program that reads all .txt files from a certain folder and then draws items based off the information found in those .txt files. Sometimes there may be 5 files, sometimes there may be 250. Is it possible to implement a progress bar so the impatient users dont think its crashed. I am able to pull the number of files ahead of time and set a variable "NUMOFTXT". I have found some progress bar/meter programs, but am having troubles implementing them into the loop. Below is the code (modified portion of the original code written by @Kent1Cooper)
(setq numoftxt (vl-directory-files FOLDER "*.txt" 1))
(SETQ NUMOFTXT (LENGTH NUMOFTXT))
(foreach txtfile (vl-directory-files folder "*.txt" 1)
(command "zoom" "w" zoompt1 Zoompt2)
(setq file (open (strcat folder txtfile) "r"))
(while (setq txt (read-line file))
(cond
((wcmatch (vl-string-trim "\t " txt) "'= FILENAME=*")
(setq txt (afterequal) txt (afterequal)); bypass (2) = signs;
(command "layer" "s" "Filename" "")
(command "_.text" "_style" "FILE" "_r" "_none" labeltxtins 0 txt)
); filename-line condition
((wcmatch (vl-string-trim "\t " txt) "TOOL*");;Start of identifying TOOL number
(setq
ToolStr (afterequal); Text string
); setq
); TOOL Number condition---Checks TOOL number in line and sets the # i.e. TOOLNAME=108 will return "108"
((wcmatch (vl-string-trim "\t " txt) "LINE*")
(setq
txt (afterequal) startX (atof (tocomma))
txt (afterequal) startY (atof (tocomma))
txt (afterequal) startZ (atof (tocomma))
txt (afterequal) endX (atof (tocomma))
txt (afterequal) endy (atof (tocomma))
endZ (atof (afterequal))
); setq
(command "layer" "s" toolstr "")
(command "_.line"
"_none" (setq lstart (list (+ startX shift) startY startZ))
"_none" (setq lend (list (+ endX shift) endY endZ))
""
); command
(setq toolstr nil)
(if part ; in a part box?
(if (= lineNo 0); then [outer] -- drew first Line of part box
(setq ; then [inner]
p1 lstart
p2 lend
lineNo 1 ; triggers part Text after next Line
); setq
(progn ; else [inner] -- second Line of part box
(setq ; then
p3 lstart
p4 lend
); setq
(command
"_.text" "_style" "PART" "_none" "_mc"
(mapcar '/ (mapcar '+ (mapcar 'min p1 p2 p3 p4) (mapcar 'max p1 p2 p3 p4)) '(2 2))
0 partStr
); command
(setq part nil); [other 2 part-box Lines ordinary]
); progn
); if [which Line just drawn]
); if [in part box]
); LINE condition
((wcmatch (vl-string-trim "\t " txt) "POINT*")
(setq
txt (afterequal) ptX (atof (tocomma))
txt (afterequal) ptY (atof (tocomma))
ptZ (atof (afterequal))
); setq
(command "layer" "s" toolstr "");;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(command "_.point" "_none" (list (+ ptX shift) ptY ptZ))
); POINT condition
((wcmatch (vl-string-trim "\t " txt) "ARC*")
(setq
txt (afterequal) startX (atof (tocomma))
txt (afterequal) startY (atof (tocomma))
txt (afterequal) ; bypass Z
txt (afterequal) endX (atof (tocomma))
txt (afterequal) endY (atof (tocomma))
txt (afterequal) ; bypass Z
txt (afterequal) ctrX (atof (tocomma))
txt (afterequal) ctrY (atof (tocomma))
); setq
(command "layer" "s" toolstr "");;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(command "_.arc"
"_none" (list (+ startX shift) startY)
"_c" "_none" (list (+ ctrX shift) ctrY)
"_none" (list (+ endX shift) endY)
); command
); ARC condition
((wcmatch (vl-string-trim "\t " txt) "PART*")
(setq
part T ; triggers use of next 2 Line specs to locate part Text
partStr (afterequal); Text string
lineNo 0
); setq
); PART-line condition
;; [no none-of-the-above condition; do nothing with other lines]
); cond
); while [lines in file]
(command "zoom" "w" zoompt1 Zoompt2)
(command "mirror" "w" mirrpt1 mirrpt2 "" midpt3 midpt4 "y")
(command "layer" "s" "customer" "")
(setq ; to shift next results over
shift (+ shift shiftinc)
labeltxtins (polar labeltxtins 0 shiftinc)
mirrpt1 (polar mirrpt1 0 shiftinc)
mirrpt2 (polar mirrpt2 0 shiftinc)
midpt1 (polar midpt1 0 shiftinc)
midpt2 (polar midpt2 0 shiftinc)
midpt3 (polar midpt3 0 shiftinc)
midpt4 (polar midpt4 0 shiftinc)
zoomt1 (polar midpt1 0 shiftinc)
zoomt2 (polar midpt2 0 shiftinc)
); setq
); foreach
Solved! Go to Solution.