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

Lisp Routine to draw Barber Shop Pole style Storm Pipe as "1" object

11 REPLIES 11
Reply
Message 1 of 12
Anonymous
903 Views, 11 Replies

Lisp Routine to draw Barber Shop Pole style Storm Pipe as "1" object

Does anyone have a lisp routine they'd like to share that draws storm pipes like barber shop poles.

 

I currently have one called pipe.lsp that draws storm pipes in tha Barber Shp Pole style, it prompts you for start and end points

then asks you the diameter of the pipe, then it draws in the barber shop pole linework for a storm pipe,  "BUT"  it draws the

storm pipe with 3 seperate line objects.

 

Anyone have an existing lisp that draws that barber shop pole style storm pipe as "1" object that you can pick and select

and get a lenght from???

11 REPLIES 11
Message 2 of 12
rkmcswain
in reply to: Anonymous

Ok, I'll bite. What is "Barber Shp Pole style"?
R.K. McSwain     | CADpanacea | on twitter
Message 3 of 12
Anonymous
in reply to: rkmcswain

It's kinda like a candy cane, a length of solid followed by a length of open followed by a length of solid etc. etc.

You could define it as a pline with a width to it, say 2' feet wide and it has a dashed linetype, then offset the pline 1' to each side and set their widths to zero and their linetype to continuous. you now have a storm drainage pipe line that is 2' wide and has 3 lines associated with it.

Message 4 of 12
smaher12
in reply to: Anonymous

Can you post a drawing or screenshot?

Message 5 of 12
Anonymous
in reply to: smaher12

Like this? This is what I got after following the instructions you gave, hopefully it is useful for persons assisting you.

stormpipe.jpg

Message 6 of 12
Anonymous
in reply to: Anonymous

storm-p.JPG

 

Should look more like this.  I'm trying to find a lisp that draws this as 1 object instead of 3.  And prompts for the width of the pipe.

Message 7 of 12
Anonymous
in reply to: Anonymous

Thanks for further explaining.

What I would do is create a dynamic block with a stretch parameter and then write a short lisp routine to insert/modify it, as well as prompt for the width. Such a routine wouldn't be too difficult and would be an excellent exercise in code.

 

Take a shot, good luck.

 

search "insert dynamic block" in these forums and on google for help.

Post here if any questions.

Message 8 of 12
Kent1Cooper
in reply to: Anonymous

Give this a look.  Width would be controlled by linetype scale.

 

[By the way, a barber pole actually has spiraling stripes....]

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

Spiraling stripes, yeah I know, but I couldn't figure out a better example at that moment to visualize it.

I'm terrible at code, I have an old linetype that uses a shape file that kinda does what I'm looking for but there are some issues with it, I was hoping the lisp experts out there may have already lisped this into a single object that can be listed for length and griped as one object rather than 3 separate lines.
Message 10 of 12
Kent1Cooper
in reply to: Anonymous


@Anonymous wrote:
.... I was hoping the lisp experts out there may have already lisped this into a single object that can be listed for length and griped as one object rather than 3 separate lines.

Those things are true of objects drawn with that OSCH linetype in the thread I posted a link to [all of what you see in each color in the image there is a single object].  They do, of course, have the same disadvantages, such as they are, of all non-continuous linetypes, such as that if the overall length doesn't relate to a multiple of the definition cycle nicely, there will be portions at the ends that are plain-continuous.

Kent Cooper, AIA
Message 11 of 12
smaher12
in reply to: Anonymous

Perhaps "group" the 3 lines? You may need to play with the ltscale for this to appear correct.

 

 

(defun C:test (/ os clt pw p1 p2 p3 p4 p5 p6 selset )
  (setvar 'cmdecho 0)
  (setq os (getvar 'osmode))
  (setq clt (getvar 'celtype))
  
  (if (not (tblsearch "ltype" "dashed"))
    (command "-linetype" "l" "dashed" "acad.lin" "")
  )
  (if
    (and
      (and
	(setq pw (getreal "\nSpecify pipe width: "))
	(setq p1 (getpoint "\nSpecify first point: "))
	)
      (setq p2 (getpoint p1 "\nSpecify second point: "))
    )
    (progn
      (setq p3 (polar p1 (- (angle p1 p2) (/ pi 2)) (/ pw 2.0))
	    p4 (polar p1 (+ (angle p1 p2) (/ pi 2)) (/ pw 2.0))
	    p5 (polar p2 (- (angle p1 p2) (/ pi 2)) (/ pw 2.0))
	    p6 (polar p2 (+ (angle p1 p2) (/ pi 2)) (/ pw 2.0))
	)
      (setvar 'osmode 0)
      (setq selset (ssadd))
      (command "_.line" p3  p5 "")
      (setq selset (ssadd (entlast) selset ))
      (command "_.line" p4  p6 "")
      (setq selset (ssadd (entlast) selset ))
      (setvar 'celtype "dashed")
      (command "_.pline" p1 "w" pw pw p2 "w" 0 0 "")
      (setq selset (ssadd (entlast) selset ))
      (command "-group" "create" "*" "" selset "")
      (setvar 'osmode os)
      (setvar 'celtype clt)
      ); progn
    ); if
 (princ)
)

 

 

 

Message 12 of 12
Kent1Cooper
in reply to: smaher12


@smaher12 wrote:

Perhaps "group" the 3 lines? ....


If grouping serves the purpose, the same could be done with any appropriate kind of entity [Line, Polyline of however many segments, or (however unlikely) Arc], without the need to calculate all those endpoints, nor worry about either object snap or whether the linetype exists in the drawing yet, if after drawing the center-line path of the pipe, you apply this [lightly tested]:

 

(defun C:MIP (/ pipesel pw pipe selset isPoly pipeobj) ; = Make [existing object] Into Pipe
  (setvar 'peditaccept 1); [save first and restore later if preferred]
  (if
    (and
      (setq pipesel (entsel "\nSelect pipe-route object: "))
      (not (redraw (car pipesel) 3)); highlight
      (setq pw (getdist "\nPipe width: "))
    ); and
    (progn
      (setq
        pipe (car pipesel)
        selset (ssadd)
        isPoly (wcmatch (cdr (assoc 0 (entget pipe))) "*POLYLINE")
        pipeobj (vlax-ename->vla-object pipe)
      ); setq
      (vla-offset pipeobj (/ pw 2)) (ssadd (entlast) selset)
      (vla-offset pipeobj (/ pw -2)) (ssadd (entlast) selset)
      (command
        "_.chprop" pipe "" "_ltype" "dashed" ""
        "_.pedit" pipe "_width" pw ""
      ); command
      (ssadd (if isPoly pipe (entlast)) selset); (entlast) only if converted Line/Arc
      (command "-group" "create" "*" "" selset "")
    ); progn
  ); if
); defun

 

Consider also whether to force an appropriate Layer, or force Continuous linetype on the sides, in case the initial object isn't Continuous.  It could use object-type constraints in selection.  You could incorporate means to convert even Circles or Ellipses or Splines into Polylines in order to give them width, but in piping drawings that doesn't seem necessary, as even Arcs or Pline arc segments may not be.  I suppose you could also have the drawing of the center-line object inside the routine, but that gets more complicated [but is certainly doable] if you want options for entity type.  And of course error handling, etc....

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