Buffer around a line-point network

Buffer around a line-point network

rajeshpatnaik2001
Advocate Advocate
960 Views
4 Replies
Message 1 of 5

Buffer around a line-point network

rajeshpatnaik2001
Advocate
Advocate

Hi,

 

I need a lisp to draw buffer polyline around a line-point network.
Any help in this regard would be highly appreciated. 

rajeshpatnaik2001_0-1617874746039.png

 

 

0 Likes
Accepted solutions (2)
961 Views
4 Replies
Replies (4)
Message 2 of 5

ВeekeeCZ
Consultant
Consultant

Google it. Plenty of routines.

 
0 Likes
Message 3 of 5

hak_vz
Advisor
Advisor
Accepted solution

 

(defun c:buffer ( /  ss bw i lst e eo p1 p2 ang1 ang2 ang3 ang4 pa pb a b c d  lst ssreg)
(setq bw (getreal "\nOffest distance from line >"))
(princ "\nSelect line enitities >")
(setvar 'cmdecho 0)
(setq ss (ssget '((0 . "LINE"))) i -1 ssreg (ssadd))
(while (< (setq i (1+ i)) (sslength ss))
(setq 
	e (ssname ss i)
	eo (vlax-ename->vla-object e)
	p1 (vlax-get eo 'Startpoint)
	p2 (vlax-get eo 'Endpoint)
	ang1 (angle p1 p2)
	ang2 (angle p2 p1)
	ang3 (+ ang1 (/ pi 2))
	ang4 (- ang1 (/ pi 2))
	pa (polar p1 ang1 (+ (distance p1 p2) bw))
	pb (polar p2 ang2 (+ (distance p2 p1) bw))
	a (polar pa ang3 bw)
	b (polar pb ang3 bw)
	c (polar pb ang4 bw)
	d (polar pa ang4 bw)
)
(command "_.pline" "_non" a "_non" b "_non" c "_non" d "c")
(command "_region" (entlast) "")
(setq ssreg (ssadd (entlast) ssreg ))
)
(command "_.union" ssreg "")
(setq ssreg nil lst (entlast))
(command "_explode" (entlast))
(while (setq lst (entnext lst))
	(setq ssreg (ssadd lst ssreg ))
)
(command "_.pedit" "m" ssreg "" "y" "j" "" "" "") 
(setvar 'cmdecho 1)
(princ)
)

 

Try this. For a simplicity code works only with line objects.

Select as a solution if it works for you. Further changes possible.

 

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.
0 Likes
Message 4 of 5

rajeshpatnaik2001
Advocate
Advocate
Accepted solution

Thanks @hak_vz   🙂
I just changed last few lines and it works fine.

 

;;;;;;;;

(defun c:buffer ( / ss bw i lst e eo p1 p2 ang1 ang2 ang3 ang4 pa pb a b c d lst ssreg)
(setq bw (getreal "\nOffest distance from line >"))
(princ "\nSelect line enitities >")
(setvar 'cmdecho 0)
(setq ss (ssget '((0 . "LINE"))) i -1 ssreg (ssadd))
(while (< (setq i (1+ i)) (sslength ss))
(setq
e (ssname ss i)
eo (vlax-ename->vla-object e)
p1 (vlax-get eo 'Startpoint)
p2 (vlax-get eo 'Endpoint)
ang1 (angle p1 p2)
ang2 (angle p2 p1)
ang3 (+ ang1 (/ pi 2))
ang4 (- ang1 (/ pi 2))
pa (polar p1 ang1 (+ (distance p1 p2) bw))
pb (polar p2 ang2 (+ (distance p2 p1) bw))
a (polar pa ang3 bw)
b (polar pb ang3 bw)
c (polar pb ang4 bw)
d (polar pa ang4 bw)
)
(command "_.pline" "_non" a "_non" b "_non" c "_non" d "c")
(command "_region" (entlast) "")
(setq ssreg (ssadd (entlast) ssreg ))
)
(command "_.union" ssreg "")
;(setq ssreg nil lst (entlast))
(command "_explode" (entlast))
;(while (setq lst (entnext lst))
; (setq ssreg (ssadd lst ssreg ))
😉
(command "_.pedit" "m" "p" "" "y" "j" "" "")
(setvar 'cmdecho 1)
(princ)
)

Message 5 of 5

hak_vz
Advisor
Advisor

You can add (initcommandversion) before pedit command to work with various versions of autocad i.e newer versions.

But if it works for you with your changes, I' more than happy.

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.
0 Likes