;; | ---------------------------------------------------------------------------- ;; | PL_BreakX ;; | ---------------------------------------------------------------------------- ;; | Function : Break the polyline at this point ;; | Argument : ;; | 'ename' - Polyline to be broken ;; | Overloaded, if 'nil', then polyline will be searched ;; | and broken at point ;; | 'pt' - point at which to break polyline ;; | Action : Breaks the polyline at the specified point. ;; | Returns : The two new entities formed out of the breaking. ;; | Comment : ;; | The point 'pt' may or may not lie on the segment of the polyline. ;; | Returns a list of (list ename ename1) where 'ename' is the original ;; | entity and 'ename1' is the last new entity. ;; | ;; | **IMPORTANT** : Please set the visitbility of the point in ;; | question BEFORE entering PL_BreakX, else the function may not run ;; | correctly. ;; | Updated : Jun 18, 2007 ;; | e-mail : rakesh.rao@4d-technologies.com ;; | Web : www.4d-technologies.com ;; | ---------------------------------------------------------------------------- (defun PL_BreakX ( ename Pt / xd odLst Tables _odLst Table Tables vlist Broke cnt ename1 StPt EndPt entl flag Found hnd1 hnd2 More OS ss ssl ) (setq Broke nil) (if (not ename) (progn (setq ss (SS_sswindow pt #WinSearchTol "C" (list (cons 0 "LWPOLYLINE,POLYLINE")))) (if ss (progn (setq ssl (sslength ss) More T Found nil cnt 0 ) (while More (setq ename (ssname ss cnt) vlist (PL_plist ename) StPt (car vlist) EndPt (last vlist) cnt (1+ cnt) ) (if (and (not (equal StPt pt #WinSearchTol)) (not (equal EndPt pt #WinSearchTol)) ) (setq More nil Found T ) ) (if (= cnt ssl) (setq More nil) ) ) (if (not Found) (setq ename nil) ) )) )) (if ename (progn (setq OS (getvar "OSMODE")) (setvar "OSMODE" 0) (setq xd (assoc -3 (entget ename (list "*")))) (if #AcadMap (progn (setq odLst '() Tables (AM_GetTables ename) ) (if Tables (progn (foreach Table Tables (setq _odLst (AM_GetTableData ename Table)) (if _odLst (setq odLst (cons _odLst odLst)) ) ) (setq odLst (reverse odLst)) )) )) (setq entl (entget ename) flag (LI_item 70 entl) hnd1 (LI_item 5 (entget (entlast))) ) (command "._Break" (list ename Pt) Pt) (setq ename1 (entlast) hnd2 (LI_item 5 (entget ename1)) ) (if (/= hnd1 hnd2) (progn (setq Broke T) (if xd (progn (setq entl (append (entget ename1) (list xd))) (entmod entl) )) (if #AcadMap (progn (setq cnt 0) (foreach Table Tables (setq _odLst (nth cnt odLst) cnt (1+ cnt) ) (AM_PutTableData ename1 _odLst Table "Overwrite") ) )) )) (setvar "OSMODE" OS) )) (if Broke (list ename ename1) nil) )