Author Topic: create buffer around pline  (Read 4839 times)

0 Members and 1 Guest are viewing this topic.

subbup

  • Guest
create buffer around pline
« on: September 28, 2004, 08:14:48 AM »
Hello All,

Thanks in advance.

I need to create buffer around a lwpolyline with specified distance.
any one have the lisp to create like this.
one more thing is
when we try to select features with ssget supplying points list is that necessary to zoom to the points list or any other way is availble to select features that falling in specified points list.
for example i want to select features that completely covered in a closed polygon. Any one have ideas. :idea:

whdjr

  • Guest
create buffer around pline
« Reply #1 on: September 28, 2004, 09:08:06 AM »
Quote from: subbup
I need to create buffer around a lwpolyline with specified distance.

What do you mean a buffer?
Quote from: subbup
i want to select features that completely covered in a closed polygon. Any one have ideas.

You can supply ssget with the points list of a polygon and it will use that as your selection window.
Quote from: Taken from the AutoCAD Help Files for SSGET
Create a selection set of the objects crossing the box from (0,0) to (1,1):

Command: (ssget "_C" '(0 0) '(1 1))

<Selection set: b>

Create a selection set of the objects inside the window from (0,0):

Command: (ssget "_W" '(0 0) '(5 5))

<Selection set: d>

Command: (setq pt_list '((1 1)(3 1)(5 2)(2 4)))

((1 1) (3 1) (5 2) (2 4))

Create a selection set of all objects crossing and inside the  polygon defined by pt_list:

Command: (ssget "_CP" pt_list)

<Selection set: 13>

Anonymous

  • Guest
create buffer around pline
« Reply #2 on: September 28, 2004, 11:59:47 PM »
buffer in the sense ineed to create closed polyline around the seleced polyline with uniform distance.
next one it's not only enough supply point list to select features with in the point list. i think we need to zoom to that point list otherwise SSGET won't work perfectly.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
create buffer around pline
« Reply #3 on: September 29, 2004, 08:48:32 AM »
Quote from: SubbuP
I need to create buffer around a lwpolyline with specified distance.
any one have the lisp to create like this.
one more thing is
when we try to select features with ssget supplying points list is that
necessary to zoom to the points list or any other way is availble to select
features that falling in specified points list.
for example i want to select features that completely covered in a closed polygon.
Any one have ideas.


Here is a subroutine that will get you started on the 'buffer'
Code: [Select]
;;  Double Offset Method - CAB  02/17/2004
;;  offset to both sides a given distance
;;  Arguments
;;    ename is an entity name
;;    dist is the offset distance
;;  Returns
;;   nil if failed or
;;   list of the two new entities
;;
(defun OffsetDouble (ename dist / vobj enew)
  (setq vobj (vlax-ename->vla-object ename))
  (if (vlax-method-applicable-p vobj 'Offset)
    (progn
      (vlax-invoke vobj 'Offset dist)
      (setq enew (entlast))
      (vlax-invoke vobj 'Offset (- dist))
      (setq enew (list (entlast) enew))
    )
    (prompt "\nCannot offset selected object type.")
  )
); defun


You will have to figure the rest.

As for the ssget, i think will answered that.
I would add that if the 'features' are on a unique layer you might try
    (ssget "_CP" pt_list '((8 . "LayName")))[/list:u]
    or
      (ssget "_CP" pt_list '((0 . "LINE")(8 . "LayName")))[/list:u]
      to filter the other objects out.

      Is there anything unique about the features you are trying to select?
      Layer, color, entity type, z-value, anything?
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

subbup

  • Guest
create buffer around pline
« Reply #4 on: October 01, 2004, 12:59:10 AM »
CAB,

problem here is if it is single segment polyline or few segments polyline I am able to do offset bothsides.
if it is a pline with more than 100 vertex or self crossed pline like that offset is not coming in proper way.
when it comes to
(ssget "_CP" pt_list '((8 . "LayName")))
problem here is if you are not zoomed to the point list that we supplied SSGET not selecting the features.

whdjr

  • Guest
create buffer around pline
« Reply #5 on: October 01, 2004, 08:52:39 AM »
What is your objective for this tool?

What are you trying to accomplish?

If we had a little bit more information we might could make a better solution or suggestion to your problem. :)

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
create buffer around pline
« Reply #6 on: October 01, 2004, 09:06:09 AM »
Some times this will work, but if your selection area is too small it may fail.
Try it.
Code: [Select]
 (command "._zoom" "E")
  (ssget "_CP" pt_list '((8 . "LayName")))
  (command "._zoom" "P")

If it does not work you will have to code a 'zoom to' routine.
If you like i can post a similar routine.

Can you upload a DWG of the polyline group you want to buffer?
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

subbup

  • Guest
create buffer around pline
« Reply #7 on: October 04, 2004, 02:46:06 AM »
my objective for this tools is
I want to select objects around polyline with a particualr distance.
for this i am trying in this way.
create a buffer (closed pline) around the pline with specific distance and
take the vertex list of new pline that we created
pass this list to SSGET to select the features.

could any one tell me how to upload dwg here, so whoever seeing this they will get idea what i am trying to do.

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
create buffer around pline
« Reply #8 on: October 04, 2004, 04:07:44 AM »
Quote from: subbup
could any one tell me how to upload dwg here, so whoever seeing this they will get idea what i am trying to do.

check this out;
http://theswamp.org/phpBB2/viewtopic.php?t=2332
TheSwamp.org  (serving the CAD community since 2003)

whdjr

  • Guest
create buffer around pline
« Reply #9 on: October 04, 2004, 11:23:40 AM »
Do you want this buffer to select all items that the buffer crosses or all items that are completely within the buffer?
I may have missed this, but is the buffer on both sides of the polyline and is the polyline closed or open?

David Bethel

  • Swamp Rat
  • Posts: 656
create buffer around pline
« Reply #10 on: October 04, 2004, 01:25:32 PM »
I'd try something like this:

Code: [Select]

(defun massoc (key alist / x nlist)
  (foreach x alist
    (if (eq key (car x))
        (setq nlist (cons (cdr x) nlist))))
  (reverse nlist))

(defun c:buf (/ fl tl bl d s pl fp ep ss i en ed ip p10 p11 lc ln)

;  (*debug* 9 "buf")

  (initget 7)
  (setq d (getdist "\nOffset Distance:   "))

  (initget 1)
  (setq s (car (entsel "\nSelect LWPLINE:   ")))
  (setq pl (massoc 10 (entget s)))

  (setq ln "TEMP1" lc 1)
  (while (tblsearch "LAYER" ln)
         (setq lc (1+ lc) ln (strcat "TEMP" (itoa lc))))
  (command "_.LAYER" "_Make" ln "")

  (command "_.MEASURE" (car pl) d)
  (setq fp (polar (car pl) (angle (cadr pl) (car pl)) d)
        ep (polar (last pl) (angle (nth (- (length pl) 2) pl) (last pl)) d))

  (setq ss (ssget "X" (list (cons 0 "POINT")(cons 8 ln))))
  (setq i (sslength ss))
  (while (not (minusp (setq i (1- i))))
         (setq en (ssname ss i)
               ed (entget en)
               ip (cdr (assoc 10 ed))
               fl (cons ip fl)))
  (setq fl (reverse fl))
  (command "_.ERASE" ss "")

  (command "_.TRACE" (* d 2) fp (car pl))
  (foreach p fl
    (command p))
  (command (last pl) ep "")

  (setq ss (ssget "X" (list (cons 0 "TRACE")(cons 8 ln))))
  (setq i (sslength ss))
  (while (not (minusp (setq i (1- i))))
         (setq en (ssname ss i)
               ed (entget en)
               p10 (cdr (assoc 10 ed))
               p11 (cdr (assoc 11 ed))
               tl (cons p10 tl)
               bl (cons p11 bl)))
  (setq tl (cons (cdr (assoc 12 ed)) tl))
  (setq bl (cons (cdr (assoc 13 ed)) bl))
  (setq tl (reverse tl))
  (command "_.ERASE" ss "")

  (command "_.LAYER" "_Set" (cdr (assoc 8 (entget s))) "")
  (command "_.PLINE")
  (foreach p tl
       (command p))
  (foreach p bl
       (command p))
  (command (car tl) "")

;  (*break*)
;  (*debug* 0 "nw_")

  (prin1))



Lot of error checking and trapping would need to be added for a robust routine.  -David
R12 Dos - A2K

subbup

  • Guest
create buffer around pline
« Reply #11 on: October 05, 2004, 01:08:07 AM »
Thanks David,
this routine is working fine. I did few modifications according to my requirements.
Thanks again. :D