;;; PJOIN.LSP by Skyler Mills May 1999 ;;; Joins lines, arcs, 2D polylines and LWpolys. ;;; If a line or arc is chosen as the parent (first) object, the routine ;;; automatically converts it to a polyline. ;;; ;;; Modified September 2000 to include LWPOLYs, differing elev. check, etc. ;;; ;;; Changed to PJOIN2 February 2001 to allow mutiple join objects, and ;;; added ;;; area and perimeter display. Also deleted some of PJOIN's elevation ;;; warnings. (defun C:PJOIN2 (/ ENTPICK HGHT JOINSET OLDECHO PEL PICKXY PAREA PLIST PLMAIN PLNEW PNAME PPERIM PWID SELSET SUB SUBEL SUBLIST SUBNAME ZEND ZSTART ) (command "_.Undo" "Begin") (setq LTGENON nil) (if (setq ENTPICK (entsel "\nSelect parent object: ")) (progn (setq OLDECHO (getvar "CMDECHO")) (setvar "CMDECHO" 0) (setq PLMAIN (car ENTPICK)) (setq PICKXY (osnap (cadr ENTPICK) "Near")) (setq PLIST (entget PLMAIN)) (setq PNAME (cdr (assoc 0 PLIST))) (if (and (or (= PNAME "POLYLINE") (= PNAME "LWPOLYLINE") ) (= 128 (boole 1 (cdr (assoc 70 PLIST)) 128)) ) (progn (command "_.PEDIT" PLMAIN "Ltype" "Off" "") (setq LTGENON T) ) ; progn ) ; if (if (or (= PNAME "LINE") (= PNAME "ARC") ) (progn (if (= PNAME "LINE") (progn (setq ZSTART (caddr (cdr (assoc 10 PLIST)))) (setq ZEND (caddr (cdr (assoc 11 PLIST)))) (if (/= ZSTART ZEND) (progn (alert "Line has differing Z's; exiting program...") (setvar "OSMODE" OLDOS) (exit) ) ; progn ) ; if ) ; progn ) ; if a line (command "_.PEDIT" PLMAIN "Y" "") (setq SELSET (ssget "L")) (setq PLMAIN (ssname SELSET 0)) (setq PLIST (entget PLMAIN)) ) ; progn ) ; if a line or arc (redraw PLMAIN 3) (prompt "\nSelect objects to be joined to parent...") (setq JOINSET (ssget)) (if (and (not (null JOINSET)) (/= 1 (boole 1 (cdr (assoc 70 PLIST)) 1)) ) (progn (command "PEDIT" PLMAIN "Width" 0.0 "JOIN" JOINSET "" "") (redraw PLMAIN 4) ;; (setq SELSET (ssget (OSNAP PICKXY "NEAR"))) (setq SELSET (ssget PICKXY)) (setq PLNEW (ssname SELSET 0)) (if (= LTGENON T) (command "_.PEDIT" PLNEW "Ltype" "On" "") ) (setq HGHT (getvar "VIEWSIZE")) ; Get height of current view (setq PWID (* 0.00714 HGHT)) ; Set polyline width to 0.3% ; of screen width ; screen width = ; (2 * VIEWSIZE) / tan(40degs) ; = (2 * VIEWSIZE) / 0.839 ; = 2.38 * VIEWSIZE ; 0.3% of screen width: ; 0.003 * 2.38 = 0.00714 (command "_.PEDIT" PLNEW "WIDTH" PWID "") ; Widen polyline to ; indicate join (getstring "\nPress enter to reset polyline width...") (command "_.PEDIT" PLNEW "WIDTH" 0. "") (command "_.Area" "Object" PLNEW) (setq PAREA (getvar "AREA")) (setq PPERIM (getvar "PERIMETER")) (prompt "\n") (princ (strcat "\nArea of polyline: " (rtos PAREA))) (princ (strcat "\nPerimeter of polyline: " (rtos PPERIM))) ) ; progn if there is a JOINSET (progn (prompt "\nNo join objects selected or polyline is closed...") ) ; progn ) ; if join objects selected ) ; progn if a parent object is picked (progn (prompt "\nNo parent object selected...") ) ; progn ) ; if a parent object is picked (command "_.UNDO" "END") (princ) )