;; | ---------------------------------------------------------------------------- ;; | PL_PlJoin ;; | ---------------------------------------------------------------------------- ;; | Function : Join Polyline or LINE segments in selection set. ;; | Author : Rakesh Rao ;; | Argument : 'ss' - The selection set to be joined. ;; | 'BoundBox' - (not used anymore) - This argument is retained for ;; | compatibility purposes but has no effect. Leave it ;; | at T or 'nil' ;; | Action : Runs the Pedit Join command until all the polylines have been ;; | joined. ;; | Updated : September 20, 2007 ;; | Comments : Two scratch layers $temp$ and $temp1$ are created. ;; | Works only on model space objects ;; | e-mail : rakesh.rao@4d-technologies.com ;; | Web : www.4d-technologies.com ;; | ---------------------------------------------------------------------------- (defun PL_PlJoin (ss BoundBox / Total ss1 ssl cnt flag nssl ename en entl tmp elast JoinSS CL Go Z1 Z2 ) (setq ss1 (ssadd)) (if ss (progn (setq ssl (sslength ss) tmp (strcat " of " (itoa ssl)) cnt 0 ) (princ "\n") (repeat ssl (setq ename (ssname ss cnt) entl (entget ename) en (LI_item 0 entl) cnt (1+ cnt) ) (if (member en (list "LINE" "ARC")) (progn (setq Go nil) (if (= en "ARC") (setq Go T) (progn (setq Z1 (caddr (LI_item 10 entl)) Z2 (caddr (LI_item 11 entl)) ) (if (= Z1 Z2) (setq Go T) ) )) (if Go (progn (command "._Pedit" ename "_Yes" "_X") (setq ename (entlast)) (ssadd ename ss1) ) (princ "\n1 3d line found and ignored.\n") ) ) (progn (if (not (member en (list "VERTEX" "SEQEND"))) (progn (if (not (PL_3d? ename)) (ssadd ename ss1) (princ "\n1 3d polyline found and ignored.\n") ) )) )) (princ (strcat "\rPre-processing polyline objects..." (itoa cnt) tmp)) ) )) (if (> (sslength ss1) 0) (setq ss ss1) (setq ss nil) ) (if ss (progn (setq Total (sslength ss) ssl Total CL (getvar "CLAYER") ) (LA_mk_c_lyr "$temp$" "") (LA_DelLayer "$temp$") (LA_mk_c_lyr "$temp1$" "") (LA_DelLayer "$temp1$") (LA_ChLay ss "$temp$") (princ "\n") (while ss (princ (strcat "\rJoining POLYLINEs : (" (rtos (fix (* (- 1.0 (/ (float ssl) Total)) 100.0)) 2 0) "% over)")) (setq ename (ssname ss 0) ssl (sslength ss) ) (if (PL_Open? ename) (progn (setq JoinSS ss) (command "._Point" (getvar "VIEWCTR")) (setq elast (entlast)) (command "._Pedit" ename "_Join" JoinSS "" "_X") (setq ss (ssget "_X" (list (cons 8 "$temp$") (cons 67 0)))) (if ss (progn (setq nssl (sslength ss)) (if (/= ssl nssl) (progn (setq ename (entlast) entl (entget ename) ) (if (and ename entl (/= (LI_item 67 entl) 1) (not (equal ename elast)) ) (LA_ChLay ename "$temp1$") ) ) (LA_ChLay ename "$temp1$") ) (setq ss (ssget "_X" (list (cons 8 "$temp$") (cons 67 0)))) )) (if (and elast (entget elast)) (entdel elast) ) ) (progn (LA_ChLay ename "$temp1$") (setq ss (ssget "_X" (list (cons 8 "$temp$") (cons 67 0)))) )) ) (princ (strcat "\rJoining POLYLINEs: (100% over)")) (setq ss (ssget "_X" (list (cons 8 "$temp1$") (cons 0 "LWPOLYLINE,POLYLINE") (cons 67 0)))) (LA_mk_c_lyr CL "") )) ss )