; ZOTO Technologies, ; 23 Greenhills Dve, ; Melton 3337. ; E-MAIL: zoltan.toth@ains.net.au ; WWW: http://www.ains.net.au/zoto/ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; Version 1.1: Removed bug that reported incorrect number of polyline ; segments when a closed polyline was created. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; This program takes any number of LINES, ARCS and/or POLYLINES and joins ; them into a single POLYLINE if the objects are contiguous. It will report ; the number of segments in the newly-created POLYLINE to help the user ; identify any non-contiguity in the objects selected. ;******************************************************************************* ;define program name & localize variables (defun C:PJOIN(/ SS2 OBJN2 OBJN3 OTYP2 VTC2 CPL2 CTR2) (setq CMD (getvar "CMDECHO")) ;save current command echo status (setvar "CMDECHO" 0) ;turn off command echoing (command "._UNDO" "_GROUP") ;start UNDO group ;get objects to join into a single POLYLINE (prompt "\nSelect objects to join into a polyline:") (setq SS2 (ssget '((-4 . "<OR")(0 . "LINE")(0 . "POLYLINE")(0 . "ARC")(-4 . "OR>"))) ) (if SS2 (progn (setq OBJN2 (ssname SS2 0)) ;get name of first object (setq OTYP2 (cdr (assoc 0 (entget OBJN2)))) ;get object type ;if first object is a POLYLINE (if (= "POLYLINE" OTYP2) ;if first object is a POLYLINE (command "._PEDIT" OBJN2 "_J" SS2 "" "") ;join objects into POLYLINE (command "._PEDIT" OBJN2 "_Y" "_J" SS2 "" "") ;convert object and join them ) ;end IF (setq OBJN3 (entlast) ;get last created object CPL2 (cdr (assoc 70 (entget OBJN3))) ;get closed/open bit ) (setq CTR2 -2) ;initialize counter CTR2 (while (setq OBJN3(entnext OBJN3)) ;while another subentity can be got (setq CTR2 (1+ CTR2)) ;increment counter ) ;inform user of number of segments in POLYLINE (if (= 1 CPL2) ;if polyline is closed (prompt (strcat "\nPolyline has " (itoa (1+ CTR2)) " segments.")) (prompt (strcat "\nPolyline has " (itoa CTR2) " segments.")) ) ) ;end PROGN (prompt "\nNo objects selected.") ) ;end IF (command "._UNDO" "_END") ;end UNDO group (setvar "CMDECHO" CMD) ;restore command echo status (princ) ;exit quietly )