Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Buffer lisp code around pline

11 REPLIES 11
Reply
Message 1 of 12
vngrupe
2517 Views, 11 Replies

Buffer lisp code around pline

Hello,

 

do anybody have lisp code to draw buffer zone around pline?

11 REPLIES 11
Message 2 of 12
Kent1Cooper
in reply to: vngrupe

Search is your friend.  Look at this.

Kent Cooper, AIA
Message 3 of 12
vngrupe
in reply to: Kent1Cooper

There is no code in that link

Message 4 of 12
Kent1Cooper
in reply to: vngrupe

I confess I didn't look closely into it, but it was just the first thing among many that was returned by a Search for only the word "buffer," and only within these Forums.  Try that, and the same with maybe additional term(s), and if it doesn't turn anything up, try a web search [out there, include AutoCAD or the name of any overlay program you're using in the Search terms].  I would be very surprised if there isn't something available already.

Kent Cooper, AIA
Message 5 of 12
vngrupe
in reply to: Kent1Cooper

I have tryed, but that codes have any bugs

Message 6 of 12
braudpat
in reply to: vngrupe

 

Hello from France

 

I am using since about 7 years a beautiful french routine from Gilles (gile)

 

The routine CORRIDORVERYNEW (you can select N plines) draw corridors/buffers (rectangle in fact) aroud plines with option to have boxes & numbering boxes & box width & box lengths & box hatches & ...

 

This routine could have a nice small improvment : an option to draw a 180 degrees arc on the first box and the same at the end (or on the last box)

So when I need arcs, I have to draw them one by one and if I have many plines with buffers/boxes (after running CORRIDORVERYNEW), it's a long work !!

 

***** If somebody can update/improve the routine I will appreciate !?

 

Anyway THANKS to Gilles (gile) !!

 

Please play with this routine ! ... Please remind that I am not at all a Lisp/VLisp developper !?

AND let me know if the routine is OK on your US/English ACAD 201X ??

 

Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


Message 7 of 12
vngrupe
in reply to: braudpat

Thanks braudpat

 

Message 8 of 12
Kent1Cooper
in reply to: vngrupe


@vngrupe wrote:

.... 

do anybody have lisp code to draw buffer zone around pline?


Try this, which works [in very limited testing] on more object types than Polylines:

 

(defun C:BUFFER ()
  (setq
    ogt (getvar 'offsetgaptype)
    pea (getvar 'peditaccept)
    buffer (getdist "\nBuffer width: ")
    esel (entsel "\nSelect object to add buffer around: ")
  ); setq
  (if
    (and
      esel
      (setq
        ent (car esel)
        edata (entget ent)
        etype (cdr (assoc 0 edata))
      ); setq
      (wcmatch etype "*LINE,ARC,CIRCLE,ELLIPSE")
      (not (wcmatch (substr (cdr (assoc 100 (reverse edata))) 5 1) "3,M"))
        ; 3D Polylines and Mlines can't be Offset
    ); and
    (progn ; then
      (setvar 'offsetgaptype 1); rounded corners
      (setvar 'peditaccept 1)

      (setq obj (vlax-ename->vla-object ent))
      (vla-offset obj buffer)
      (setq e1 (entlast))
      (vla-offset obj (- buffer))
      (setq e2 (entlast))
      (if (and (not (vlax-curve-isClosed ent)) (/= etype "XLINE"))
        ; open-ended object other than Xline -- wrap Arcs around ends
        (progn ; then
          (command
            "_.arc" (vlax-curve-getStartPoint e1) "_e" (vlax-curve-getStartPoint e2)
              "_direction" (angtos (+ (angle '(0 0 0) (vlax-curve-getFirstDeriv e1 (vlax-curve-getStartParam e1))) pi))
            "_.arc" (vlax-curve-getEndPoint e1) "_e" (vlax-curve-getEndPoint e2)
              "_direction" (angtos (angle '(0 0 0) (vlax-curve-getFirstDeriv e1 (vlax-curve-getEndParam e1))))
          ); command
          (if (not (wcmatch etype "SPLINE,ELLIPSE"))

            (command "_.pedit" e1 "_join" "_all" "" ""); connect them
          ); if
        ); progn [close ends]
      ); if
    ); progn [valid object]
  ); if
  (setvar 'offsetgaptype ogt)
  (setvar 'peditaccept pea)
  (princ)
); defun

 

I find it can have unexpected results in certain circumstances, e.g. when the original object is a Spline or Polyline with too-tight curvatures or bends relative to the buffer width, especially at the ends, or [of course] an Arc whose radius is smaller than the buffer width.  But under "expected" circumstances it seems to work.

 

It also should be enhanced in various ways, e.g. to remember the buffer width, add error handling and command-echo suppression, etc.

Kent Cooper, AIA
Message 9 of 12
vngrupe
in reply to: Kent1Cooper

thanks Kent1Cooper

Message 10 of 12
Kent1Cooper
in reply to: vngrupe

You're welcome -- that was quick!  So quick that I should point out that I "fixed" a little something, so if you copied it out before I Edited it, do it again.

Kent Cooper, AIA
Message 11 of 12
braudpat
in reply to: Kent1Cooper

 

Hello Kent

 

Beautiful ! Thanks !!

 

My "ultimate" dream : to get your 180 degres arcs on the CORRIDORVERYNEW routine of Gilles (gile) ...

 

My "modest" dream : a new version of your routine able to run on many selected objects ...

 

Regards & Admiration, Bye, Patrice

 

Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


Message 12 of 12
Kent1Cooper
in reply to: Kent1Cooper


@Kent1Cooper wrote:

.... 

It also should be enhanced in various ways, e.g. to remember the buffer width, add error handling and command-echo suppression, etc.


Here's a fleshed-out version with those enhancements, @braudpat's multiple-object request, plus many more, much further developed in response to this thread.

Kent Cooper, AIA

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost