Help. LISP Create polyline from location end of lines

Help. LISP Create polyline from location end of lines

daohaquang
Enthusiast Enthusiast
1,311 Views
6 Replies
Message 1 of 7

Help. LISP Create polyline from location end of lines

daohaquang
Enthusiast
Enthusiast

 

Previously I have a topic about Draw Line from justify of the Text. Now I want to add a command to create a polyline from location end points of the line like in the image. Help me. Sorry for using Google translate.434343.JPG

 

0 Likes
Accepted solutions (1)
1,312 Views
6 Replies
Replies (6)
Message 2 of 7

ВeekeeCZ
Consultant
Consultant
Accepted solution
(defun c:PLends ( / l)

  (and (setq l (ssget '((0 . "LINE"))))
       (setq l (vl-remove-if 'listp (mapcar 'cadr (ssnamex l))))
       (setq l (mapcar '(lambda (e) (cdr (assoc 11 (entget e)))) l))
       (setq l (vl-sort l '(lambda (p q) (< (car p) (car q)))))
       (entmake (append (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") (cons 90 (length l)) '(70 . 0) '(62 . 1))
			(mapcar '(lambda (p) (cons 10 p)) l))))
  (princ)
  )
Message 3 of 7

daohaquang
Enthusiast
Enthusiast
Thank you so much, You are pro
I have one more small problem, I want 1 lisp to export the line length to text.
1. Select line (pline)
2. Export to existing text
Can you help me?
0 Likes
Message 4 of 7

hak_vz
Advisor
Advisor

@daohaquang  Something like this?

 

(defun c:lengthToText ( / le lo te to)
	(cond 
		((and (setq le (car(entsel "\nSelect entity to extract length >"))))
			(setq lo (vlax-ename->vla-object le))
			(cond 
				((vlax-property-available-p lo 'Length )
					(cond 
						((and(setq te (car(entsel "\nSelect text to write length >"))))
								(setq to (vlax-ename->vla-object te))
								(vlax-put to 'TextString  (rtos (vlax-get lo 'Length) 2 3))
						)
					)
				)
			)
		)
	)
)

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 5 of 7

pbejse
Mentor
Mentor

@daohaquang wrote:

 

Previously I have a topic about Draw Line from justify of the Text.


(Defun c:LFDTJ (/ ss i e data p val l ep pl te )
  (if (setq l  nil
	    ss (ssget '((0 . "TEXT") (1 . "*#.#*")))
      )
    (progn
      (repeat (setq i (sslength ss))
	(setq e (ssname ss (Setq i (1- i))))
	(setq data (mapcar '(lambda (dx)
			      (cdr (assoc dx (entget e)))
			    )
			   '(10 11 1 8)
		   )
	)
	(and (numberp (setq val (read (Caddr data))))
	     (entmakex (list (cons 0 "LINE")
			     (cons 8 (last data))
			     (cons 10
				   (setq p (if (vl-every 'zerop (Cadr data))
					     (car data)
					     (cadr data)
					   )
				   )
			     )
			     (cons 11 (setq ep (polar p (/ pi 2.0) val)))
		       )
	     )
	     (setq l (cons ep l))
	)
      )
      (and
	(setq l (vl-sort l '(lambda (p q) (< (car p) (car q)))))
        (setq pl (entmakex (append (list '(0 . "LWPOLYLINE")
			     '(100 . "AcDbEntity")
			     '(100 . "AcDbPolyline")
			     (cons 90 (length l))
			     '(70 . 0)
			     '(62 . 1))
		       (mapcar '(lambda (p) (cons 10 p)) l))
		       )
	      )
	(setq te (car (entsel "\nSelect text to write length >")))
	(setpropertyvalue te "Textstring" (rtos (getpropertyvalue pl "Length") 2 3)))
    )
  )
  (princ)
)

HTH

Message 6 of 7

daohaquang
Enthusiast
Enthusiast
Sorry I just need LISP Create polyline from location end of lines, and lisp export the line length to text is another lisp, I had lisp export the line length to text, You can repair you lisp to "Draw Line from justify of the Text" and "Create polyline from location end of lines" and remove "export the line length to text".
Thank so much
0 Likes
Message 7 of 7

ВeekeeCZ
Consultant
Consultant

Post 2 dwgs. Before and after to clearly see what you want.

0 Likes