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,
(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)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;