Author Topic: Help with program that will count fittings for pipe  (Read 1611 times)

0 Members and 1 Guest are viewing this topic.

khoa

  • Mosquito
  • Posts: 2
Help with program that will count fittings for pipe
« on: August 15, 2020, 07:30:26 AM »
Hi,

I know this isn't anything new, but I couldn't find any available lsp so I've been teaching myself autolisp. I draw 2D fire sprinkler plans. Plans use only two pipes sizes on different layers and sprinkler heads are blocks at tee fittings or end of the pipe on a elbow. We don't use blocks for fittings. All pipes/lines are broken intersections... tees (risers, sprk heads), elbows, cross. I think its silly they've been using a click counter to make the order list.

My approach use a dotted pair list to describing coordinates of spt and ept of each line and count the shared points. Then compare angles of the liens to determine which is what.

Processing points with lines with 2 points... I'm stuck at how to get the two lines to variables to make a comparison. Is there a smarter way to do this? Please teach me how this solution should be approached. Also, I think it would be a good idea that approach leaves it open the ability to label or insert a block that indicates the fitting type for easier reviewing. Much appreciate the help guys.

Please below on how far I've gotten.

Thank you,

 
Code: [Select]
(defun c:ftct () ;(/ index ss index len ept ang spt obj)   ;;returns list of elbows, tees, cross fitting count
 (setq index -1
       parsedlist nil
       cntct nil
       ss nil     
       ept nil
       ang nil
       spt nil
       obj nil
       sslist nil
       ssang1 nil
       ssang2 nil
       n nil
       ftpt nil
       ss1 nil)
 
 
 (setq ss (ssget '((0 . "LINE") (8 . "PIPE_BRANCH,PIPE_MAIN")))) ;selection set of pipes. Pipe_Branch and Pipe_Main indicate two pipe sizes. sections of pipes are broken at intersection (fitting) and share the exact coordinate points
 (while (< (setq index (1+ index)) (sslength ss))
  (progn (setq obj (vlax-ename->vla-object (ssname ss index))
       ept (vlax-get obj 'endpoint)
       spt (vlax-get obj 'startpoint)
       ang (angle spt ept))
   
(setq parsedlist (cons ept parsedlist)  ;list of start and end point coordinates of lines
       parsedlist (cons spt parsedlist))
   
         (setq ssang1 (list spt ang)
               ssang2 (list ept ang))
   
         (setq sslist (cons ssang1 sslist)        
       sslist (cons ssang2 sslist))  ; list that describe's line's angle ( angle will be used to determine whether fitting will be elbow (pipe 90degree bend) or tee fitting (sprinkler head connection)
   );progn
  );while

 (setq cntct (LM:CountItems parsedlist))   ;; dotted pair list that describes lines sharing same spt or ept coordinate



 
;(foreach n cntct (if (= (cdr n) 2) ;process cntct lookign for points with 2 connections. 2 connection points are elbows or tee fitting to sprinker head.
;(progn
; (setq ftpt (car n))
; (setq ss1 (ssget ftpt))
; (setq lineang1 (assoc  ; determine angle of line???
    ;   )))

 
 );defun






;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; SUBROUTINE FUNCTION  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;        
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun LM:CountItems  (l / c x)
 (if (setq x (car l))
  (progn (setq c (length l)
       l (vl-remove x (cdr l)))
(cons (cons x (- c (length l))) (LM:CountItems l)))))


;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;





BIGAL

  • Swamp Rat
  • Posts: 1398
  • 40 + years of using Autocad
Re: Help with program that will count fittings for pipe
« Reply #1 on: August 16, 2020, 09:15:33 PM »
Your making life hard for your self by not using block fittings, Tee, reducer etc quantities would just come out, it would be easy to draw lines add TEE and trim the line the few mm of pipe that would be removed. You can have multi blocks on 1 pt TEE, RISER, SPRINKLER, use layers or the blocks can be just a point very short line etc Riser a circle dia can be like 0.00001 so don't see but is there.
A man who never made a mistake never made anything

khoa

  • Mosquito
  • Posts: 2
Re: Help with program that will count fittings for pipe
« Reply #2 on: August 17, 2020, 12:07:54 AM »
Yeah it seems that commonly blocks for fittings which makes counting easier.

This is just how the company does things. I think it would be harder to convince them to change their design process lol.

BIGAL

  • Swamp Rat
  • Posts: 1398
  • 40 + years of using Autocad
Re: Help with program that will count fittings for pipe
« Reply #3 on: August 17, 2020, 12:28:16 AM »
Have a look at any other sprinkler software they all use smart blocks.

Just go "It takes 20 mins to get quantities v's the suggested 2 seconds" using blocks, look at Dataextraction about 1 minute.

A man who never made a mistake never made anything

d2010

  • Bull Frog
  • Posts: 323
Re: Help with program that will count fittings for pipe
« Reply #4 on: August 17, 2020, 06:00:17 AM »
 You see, I transform your-program to "Autopipe_original.lsp"
Bottom-image is corect and good-result.
Can you fix autopipe_original.lsp for good result inside "ftct sample2007a.dwg" ?
For good video , you must see winpipe.gif(bellow here).
Please  Help me for understand.
« Last Edit: August 19, 2020, 03:48:37 PM by d2010 »

BIGAL

  • Swamp Rat
  • Posts: 1398
  • 40 + years of using Autocad
Re: Help with program that will count fittings for pipe
« Reply #5 on: August 19, 2020, 08:51:41 PM »
To khoa you say your breaking the pipes so why would you not do the breaks and insert a correct fitting at same time just window the intersection, 2 lines, 3 or 4 lines etc.

Check this out https://autolispprograms.wordpress.com/fire-fighting/ Tharwat supports multiple forums.
A man who never made a mistake never made anything