Change Lisp routine to get pipe dia after insertion and draw splitter

Change Lisp routine to get pipe dia after insertion and draw splitter

Anonymous
Not applicable
832 Views
7 Replies
Message 1 of 8

Change Lisp routine to get pipe dia after insertion and draw splitter

Anonymous
Not applicable

I got attached lisp which I have stripped off from a long lisp routine to suit my need from here. I managed to dis-continue pipe drawing after inserting splitter but cannot figure out how to:

1) neatly get rid of draw a pipe in the beginning and goes to splitter2 function (after asking the pipe dia and insertion point) and just draw the splitter without any extra pipe.

2) Is there any way to hatch this bounded area in this routine?

 

appreciated your time!

0 Likes
Accepted solutions (1)
833 Views
7 Replies
Replies (7)
Message 2 of 8

ВeekeeCZ
Consultant
Consultant
Post a dwg with example of what you have and with what you want to have.
0 Likes
Message 3 of 8

sam_safinia
Advocate
Advocate

... 

 

0 Likes
Message 4 of 8

Anonymous
Not applicable

oh, sorry. Here it is

0 Likes
Message 5 of 8

ВeekeeCZ
Consultant
Consultant

Try this code... 

 

(defun C:splitter2 (/	  ss	l     pt1   a	  twidth      s-dw1
		    s-dw2 s	cosa  xlen  1o2	  p1	p2    p3
		    ro2	  intpt
		   )

  (if (and (not (initget 1))
	   (setq pt1 (getpoint "\nInsertion point: "))
	   (setq a (getangle pt1 "\nAngle: "))
	   (not (initget 7))
	   (setq twidth (getreal "\nEnter pipe dia: "))
	   (not (initget 7))
	   (setq s-dw1 (getreal "\nWidth of Left Branch Duct: "))
	   (not (initget 7))
	   (setq s-dw2 (getreal "\nWidth of Right Branch Duct: "))
      )
    (progn
      (setq s-rt (- a (/ pi 2.0)))
      (setq s-rt2 (+ a (/ pi 2.0)))
      (setq rad1 (* 2.0 s-dw1))
      (setq rad2 (* 2.0 s-dw2))
      (setq c (+ s-dw1 s-dw2 twidth))
      (setq cosA (/ (- (+ (* RAD1 RAD1) (* c c)) (* RAD2 RAD2))
		    (* 2.0 RAD1 c)
		 )
      )
      (setq xlen (* cosA rad1))
      (setq 1o2 (polar pt1 (+ a (/ pi 2.0)) (/ twidth 2.0)))
      (setq p1 (polar 1o2 s-rt2 s-dw1))
      (setq p2 (polar p1 a s-dw1))
      (setq p3 (polar p2 a s-dw1))
      (setq xpt (polar p1 s-rt xlen))
      (setq ylen (sqrt (- (* rad1 rad1) (* xlen xlen))))
      (setq intpt (polar xpt a ylen))
      (setq l  (entlast)
	    ss (ssadd)
      )
      (command "arc" intpt "c" p1 p3)
      (command "arc" 1o2 "c" p1 p2)
      (command "line" p2 p3 "")
      (setq ro2 (polar pt1 (- a (/ pi 2.0)) (/ twidth 2.0)))
      (setq p1 (polar ro2 s-rt s-dw2))
      (setq p2 (polar p1 a s-dw2))
      (setq p3 (polar p2 a s-dw2))
      (command "arc" p3 "c" p1 intpt)
      (command "arc" p2 "c" p1 ro2)
      (command "line" p2 p3 "")
      (command "line" 1o2 ro2 "")
      (while (setq l (entnext l))
	(ssadd l ss)
      )
      (setvar "PEDITACCEPT" 1)
      (command "_.PEDIT" "_m" ss "" "_j" "0." "")
      (command "_.-HATCH" "_s" "_l" "" "")
    )
  )
  (princ)
)
0 Likes
Message 6 of 8

Anonymous
Not applicable

Again amazing BeeKeeCZ,

 

- How is that possible to add all elements(lines,hatches,.) into one entity like a block? (I am thinking how I can name the block if I have 20 of them...maybe "SPL+Size1xSize2xSize3+ and index" )

 

- How can I add a simple text to the end of each branches to reflect its size?

 

- is there any way to have predefined size list to choose from instead of input the numbers? (thinking to a menu to pupping up and choose from in dynamic block could retrieve property of DB to choose the size from) 

 

I can work out now to add bits and pieces to make it works the way that I want.

Thanks again!

 

0 Likes
Message 7 of 8

ВeekeeCZ
Consultant
Consultant
Accepted solution

Hi. I added first 2 points.. Not sure about third... I would have to rewrite it alot and you don't get much of benefit... I think input parameters are simple enough. Maybe consider a dynamic block with look-up feature.

 

Spoiler
(defun C:splitter2 (/	  ss	l     pt1   a	  twidth      s-dw1
		    s-dw2 s	cosa  xlen  1o2	  p1	p2    p3
		    ro2	  intpt
		   oOSMODE i)

  (if (and (not (initget 1))
	   (setq pt1 (getpoint "\nInsertion point: "))
	   (setq a (getangle pt1 "\nAngle: "))
	   (not (initget 7))
	   (setq twidth (getreal "\nEnter pipe dia: "))
	   (not (initget 7))
	   (setq s-dw1 (getreal "\nWidth of Left Branch Duct: "))
	   (not (initget 7))
	   (setq s-dw2 (getreal "\nWidth of Right Branch Duct: "))
      )
    (progn
      (setq oOSMODE (getvar 'OSMODE))
      (setvar 'OSMODE 0)
      (setq s-rt (- a (/ pi 2.0)))
      (setq s-rt2 (+ a (/ pi 2.0)))
      (setq rad1 (* 2.0 s-dw1))
      (setq rad2 (* 2.0 s-dw2))
      (setq c (+ s-dw1 s-dw2 twidth))
      (setq cosA (/ (- (+ (* RAD1 RAD1) (* c c)) (* RAD2 RAD2))
		    (* 2.0 RAD1 c)
		 )
      )
      (setq xlen (* cosA rad1))
      (setq 1o2 (polar pt1 (+ a (/ pi 2.0)) (/ twidth 2.0)))
      (setq p1 (polar 1o2 s-rt2 s-dw1))
      (setq p2 (polar p1 a s-dw1))
      (setq p3 (polar p2 a s-dw1))
      (setq xpt (polar p1 s-rt xlen))
      (setq ylen (sqrt (- (* rad1 rad1) (* xlen xlen))))
      (setq intpt (polar xpt a ylen))
      (setq l  (entlast)
	    ss (ssadd)
      )
      (command "arc" intpt "c" p1 p3)
      (command "arc" 1o2 "c" p1 p2)
      (command "line" p2 p3 "")
      (setq ro2 (polar pt1 (- a (/ pi 2.0)) (/ twidth 2.0)))
      (setq p1 (polar ro2 s-rt s-dw2))
      (setq p2 (polar p1 a s-dw2))
      (setq p3 (polar p2 a s-dw2))
      (command "arc" p3 "c" p1 intpt)
      (command "arc" p2 "c" p1 ro2)
      (command "line" p2 p3 "")
      (command "line" 1o2 ro2 "")
      (while (setq l (entnext l))
	(ssadd l ss))
      (setvar "PEDITACCEPT" 1)
      (setq l (entlast))
      (command "_.PEDIT" "_m" ss "" "_j" "0." "")
      (setq ss nil
	    ss (ssadd))
      (command "_.-HATCH" "_s" "_l" "" "")
      (command "text" intpt "" "" (rtos twidth))
      (command "text" 1o2 "" "" (rtos s-dw1))
      (command "text" ro2 "" "" (rtos s-dw2))
      (while (setq l (entnext l))
	(ssadd l ss))
      (setq name (strcat "SPL+" (rtos twidth 2 0) "x" (rtos s-dw1 2 0) "x" (rtos s-dw2 2 0) ".")
	    i 1)
      (while (tblsearch "BLOCK" (strcat name (itoa i))) (setq i (1+ i)))
      (command "_.-BLOCK" (strcat name (itoa i)) intpt ss "")
      ;(command "_.OOPS")
      (command "_.-INSERT" (strcat name (itoa i)) intpt 1 "" "")
      (setvar 'OSMODE oOSMODE)
    )
  )
  (princ)
)
Message 8 of 8

Anonymous
Not applicable

That is great BeeKeeCZ, I'll update this thread whatever that I can add extra

Thank you again.

0 Likes