Visual LISP, AutoLISP and General Customization

Reply
Distinguished Contributor
Posts: 288
Registered: ‎05-09-2008
Message 1 of 10 (141 Views)

Place a line behind other items

141 Views, 9 Replies
11-13-2012 02:20 PM

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

Lines.PNG

IV 2010
*Expert Elite*
Posts: 2,370
Registered: ‎11-24-2009
Message 2 of 10 (126 Views)

Re: Place a line behind other items

11-13-2012 07:58 PM in reply to: ozitag

Use attribute block with wipeout as part of the block

Create polylines then insert the block

 

 

 

 

 

Distinguished Contributor
Posts: 288
Registered: ‎05-09-2008
Message 3 of 10 (120 Views)

Re: Place a line behind other items

11-13-2012 10:51 PM in reply to: pbejse

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

 

IV 2010
*Expert Elite*
Posts: 2,370
Registered: ‎11-24-2009
Message 4 of 10 (117 Views)

Re: Place a line behind other items

11-13-2012 11:04 PM in reply to: 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

 

 

 

 

 

Distinguished Contributor
Posts: 288
Registered: ‎05-09-2008
Message 5 of 10 (114 Views)

Re: Place a line behind other items

11-13-2012 11:18 PM in reply to: pbejse

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

IV 2010
*Expert Elite*
Posts: 2,370
Registered: ‎11-24-2009
Message 6 of 10 (108 Views)

Re: Place a line behind other items

11-13-2012 11:41 PM in reply to: 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

 

 

Distinguished Contributor
Posts: 288
Registered: ‎05-09-2008
Message 7 of 10 (104 Views)

Re: Place a line behind other items

11-14-2012 12:06 AM in reply to: pbejse

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.

 

 

 

IV 2010
*Expert Elite*
Posts: 2,370
Registered: ‎11-24-2009
Message 8 of 10 (94 Views)

Re: Place a line behind other items

11-14-2012 01:04 AM in reply to: ozitag

Interesting routine oztag :smileyhappy:

I'll have a look see and get back to you in a few.

 

 

Distinguished Contributor
Posts: 288
Registered: ‎05-09-2008
Message 9 of 10 (90 Views)

Re: Place a line behind other items

11-14-2012 01:16 AM in reply to: pbejse

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.

IV 2010
*Expert Elite*
Posts: 2,370
Registered: ‎11-24-2009
Message 10 of 10 (84 Views)

Re: Place a line behind other items

11-14-2012 02:22 AM in reply to: 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

 

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you interested in helping shape the Autodesk Community?
We’re looking at a few different ways to improve the “All Forums” landing page and need your feedback! If interested, please take a few minutes to fill out the following Usability Study. Thank you for your time!

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community