;; | ---------------------------------------------------------------------------- ;; | PL_UpdatePoly ;; | ---------------------------------------------------------------------------- ;; | Function : Update a polyline entity with a new vertex list. This ensures that ;; | all polyline properties, including the handle are maintained ;; | Arguments: ;; | 'ename' - Polyline entity name - supports both heavy and light ;; | weight ones ;; | 'vlist2' - New vertex list (must be in WCS co-ordinates) ;; | Action : Modifies the existing polyline through Pedit and recreates the ;; | polyline as per new vlist2 ;; | Both handle as well as Xdata is retained ;; | Updated : November 2, 1998 ;; | e-mail : rakesh.rao@4d-technologies.com ;; | Web : www.4d-technologies.com ;; | ---------------------------------------------------------------------------- (defun PL_UpdatePoly( ename vlist2 / vlist1 len1 len2 diff cnt os Vec210 NotP entl _vlist1 _vlist2 ) (setq os (getvar "OSMODE")) (setvar "OSMODE" 0) (setq entl (entget ename) Vec210 (LI_item 210 entl) vlist1 (PL_plist ename) len1 (length vlist1) len2 (length vlist2) diff (- len2 len1) ) (if (not (equal Vec210 (list 0.0 0.0 1.0))) (setq NotP T) (setq NotP nil) ) (if NotP (progn (command "._Ucs" "_OBject" ename) (setq _vlist1 (mapcar '(lambda (x) (trans x ename 1)) vlist1) _vlist2 (mapcar '(lambda (x) (trans x 0 1)) vlist2) ) ) (setq _vlist1 vlist1 _vlist2 vlist2 )) (GE_Zoom2Lst (append _vlist1 _vlist2)) (cond ((< diff 0) ; New polyline contains lesser vertices than old one (command "._Pedit" ename "_Edit") (command "_Straighten") (repeat (1+ (abs diff)) (command "_Next") ) (command "_Go") (command "_X" "_X") ) ((> diff 0) ; New polyline contains more vertices than old one (command "._Pedit" ename "_Edit") (repeat diff (command "_Insert" (getvar "VIEWCTR") "_Next") ) (command "_X" "_X") ) ) (command "._Pedit" ename "_Edit") (setq cnt 0) (repeat len2 (command "_Move" (nth cnt _vlist2) "_Next") (setq cnt (1+ cnt)) ) (command "_X" "_X") (if NotP (command "._Ucs" "_Previous") ) (setvar "OSMODE" os) )