Hi guys,
I have a lisp file that reads in a point list from a text file and creates a number with a circle around it for every point, then a line from one circle to the next in line with the center point of each circle. Is there a simple way of making the lines "go behind the circles". The portion of code that creates the circles, lines and text is as follows and a cutout screen dump of what it looks like is below.
Thanks in advance.
Ozitag
.......
(setq amount 0)
(foreach item lines
;;; ;;
;;; Create the text ;;
;;; ;;
(setq x (+ (atof (nth 2 item)) (car pt_origin)))
(setq y (+ (atof (nth 3 item)) (cadr pt_origin)))
(setq amount (+ amount 1))
(entmake (append
'((0 . "MTEXT") (100 . "AcDbEntity") (8 . "POSITIONS") (100 . "AcDbMText"))
(list (list 10 x y 0.0))
(list (cons 40 textheight))
'((41 . 0.0) (71 . 5) (72 . 5))
(list (cons 1 (nth 0 item)))
'((7 . "Standard") (210 0.0 0.0 1.0) (11 1.0 0.0 0.0))
(list (cons 50 textrotation))
'((73 . 1) (44 . 1.0))
);end append
);end entmake
;;; ;;
;;; Create the circle ;;
;;; ;;
(entmake (append
'((0 . "CIRCLE") (100 . "AcDbEntity") (8 . "POSITIONS") (100 . "AcDbCircle"))
(list (list 10 x y 0.0))
(list (cons 40 radius))
'((210 0.0 0.0 1.0))
);end append
);end entmake
;;; ;;
;;; Create the lines ;;
;;; ;;
(setq pt_current (list x y))
(if pt_previous
(progn
(setq pt_end (polar pt_current (angle pt_current pt_previous) radius)
pt_start (polar pt_previous (angle pt_previous pt_current) radius)
)
(entmake (append
'((0 . "LWPOLYLINE") (100 . "AcDbEntity") (8 . "POSITIONS") (100 . "AcDbPolyline") (90 . 2) (70 . 0) (43 . 0.0) (38 . 0.0) (39 . 0.0))
(list (list 10 (car pt_start) (cadr pt_start)))
'((40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0))
(list (list 10 (car pt_end) (cadr pt_end)))
'((40 . 0.0) (41 . 0.0) (42 . 0.0) (91 . 0) (210 0.0 0.0 1.0))
);end append
);end entmake
);end progn
);end if
(setq pt_previous pt_current)
);end forseach
I'm not 100% sure what you mean here. Is it that I make a block that is a circle with wipeout, then run through the list and place the lines, then run through the list again and place these blocks and the number text?
Ozitag
@ozitag wrote:I'm not 100% sure what you mean here. Is it that I make a block that is a circle with wipeout, then run through the list and place the lines, then run through the list again and place these blocks and the number text?
Ozitag
Good point ozitag, you could iterate through the list once then invoke a draworder after completion.
Holler if you need help
I'm going to holler for help with this one. I haven't touched drawing order or wipeout in lisp before. In fact I haven't done that much lisp at all, just lately I've got into it a bit. If you can lead me in the right direction maybe I can fumble my way through.
Thanks.
Ozitag
@ozitag wrote:I'm going to holler for help with this one. I haven't touched drawing order or wipeout in lisp before. In fact I haven't done that much lisp at all, just lately I've got into it a bit. If you can lead me in the right direction maybe I can fumble my way through.
Thanks.
Ozitag
Is that one continuous polyline? Then you do need to iterate through the list twice, if not we can write the code to place the blocks two at a time then create the line.
post a line of text here from your source file
No they are all individual lines, but it wouldn't matter if they were one continuous line.
Attached is the entire lsp code as well as a txt file to read from. The are a few questions that come up during the sequence. These are:
Text höjd (text height) the default will work for you
Text riktning (text direction) again, the default
Cirkel diameter (circle diameter) default
Choose the txt file.
Skriver linjerna mellan plockpositioner (draw the lines between the positions) Y
Skriver sargen med plockpositioner (draw outside ring) your choice of yes or no, no is shorter and less stuff to worry about.
Klick på var plockcentrum ska ligger (Click where the positions center should lie) Default is 0,0. Whatever you like.
Thanks,
Ozitag
PS any other advice on the code would be welcome as well. This is really my first largish program so comments are welcome.
I can tell you it saves a lot of time. I wrote a routine that goes the other way too, creates the text file.
Thanks for your time.
Ozitag.
a sample code and block
(defun c:sample ( / spc _delFinder _insert pt_ file f data) (vl-load-com) (setq spc (vlax-get (vla-get-ActiveLayout (vla-get-activedocument (vlax-get-acad-object))) 'Block)) (defun _insert (sp bn pt) (car (vlax-invoke (vlax-invoke sp 'InsertBlock pt bn 1 1 1 0) 'Getattributes))) (defun _delFinder (str md / d l str) (while (setq d (vl-string-position md str nil T)) (setq l (cons (substr str (+ 2 d)) l) str (substr str 1 d))) (cons str l) ) (defun pt_ (lst) (mapcar '(lambda (p) (distof (nth p lst)) ) '(2 3 4) ) ) (if (and (tblsearch "BLOCK" "TEST") (setq data nil sendtoback (ssadd) file (getfiled "Väljer en robot .txt fil" "" "txt" 144)) (setq f (open file "r"))) (progn (while (setq a (read-line f)) (setq data (append data (list (_delFinder a 9))))) (close f) (setq data (member (assoc "1" data) data)) (mapcar '(lambda (j k) (vla-put-textstring (_insert spc "TEST" (setq pt1 (pt_ j))) (car j)) (entmakex (list (cons 0 "LINE") (cons 10 pt1) (cons 11 (pt_ k)))) (ssadd (entlast) sendtoback)) data (cdr data)) (vla-put-textstring (_insert spc "TEST" (pt_ (last data))) (car (last data))) (command "_draworder" sendtoback "" "_Back" ) ) )(princ) )
see attached sample block