- ;;利用OFFSET特性(对SPLINE & ELLIPSE OFFSET后会增加控制点)
- ;;SPLINE & ELLIPSE TO PLINE
- ;;BY 龙龙仔(LUCAS)
- (defun C:S2P (/ HOLDOSMODE HOLDECHO SSS SSL N N1 ENT PT_LIST NUMPT ED PT PT1)
- ;;T. Tanzillo
- (defun VLISP-REMOVE-IF-NOT (KEY LST)
- (mapcar 'cdr
- (vl-remove-if-not
- '(lambda (E) (eq (car E) KEY))
- LST
- )
- )
- )
- (defun MIDPOINT (PT1 PT2)
- (mapcar
- '(lambda (X Y)
- (* 0.5 (+ X Y))
- )
- PT1
- PT2
- )
- )
- (setq HOLDECHO (getvar "cmdecho"))
- (setvar "cmdecho" 0)
- (command "_.undo" "group")
- (setq HOLDOSMODE (getvar "osmode"))
- (setvar "osmode" 0)
- (prompt "\n选取SPLINE,ELLIPSE:")
- (setq SSS (ssget '((0 . "ELLIPSE,SPLINE"))))
- (setq SSL (sslength SSS)
- N 0
- )
- (repeat SSL
- (prompt (strcat "\r余 " (itoa (- SSL N)) " 个物件 "))
- (setq ENT (vlax-ename->vla-object (ssname SSS N)))
- (vl-catch-all-apply
- 'vla-offset
- (list ENT 0.001)
- )
- (setq ENT (entlast))
- (vl-catch-all-apply
- 'vla-offset
- (list (vlax-ename->vla-object ENT) -0.001)
- )
- (entdel ENT)
- (setq ENT (entlast))
- (setq PT_LIST (VLISP-REMOVE-IF-NOT 10 (setq ED (entget ENT))))
- (setq ENT (vlax-ename->vla-object ENT))
- (setq N1 0)
- (vl-cmdf "_.pline" (nth N1 PT_LIST) "A")
- (if (or (and (= (cdr (assoc 0 ED)) "ELLIPSE")
- (= (cdr (assoc 42 ED)) (* pi 2))
- )
- (and (= (cdr (assoc 0 ED)) "SPLINE")
- (= (logand (cdr (assoc 70 ED)) 1) 1)
- )
- )
- (setq NUMPT (- (length PT_LIST) 2))
- (setq NUMPT (- (length PT_LIST) 1))
- )
- (repeat NUMPT
- (setq PT (vlax-curve-getclosestpointto
- ENT
- (MIDPOINT (nth N1 PT_LIST)
- (setq PT1 (nth (1+ N1) PT_LIST))
- )
- )
- )
- (vl-cmdf "S"
- (vlax-curve-getclosestpointto ENT PT)
- (vlax-curve-getclosestpointto ENT PT1)
- )
- (setq N1 (1+ N1))
- )
- (if (or (and (= (cdr (assoc 0 ED)) "ELLIPSE")
- (= (cdr (assoc 42 ED)) (* pi 2))
- )
- (and (= (cdr (assoc 0 ED)) "SPLINE")
- (= (logand (cdr (assoc 70 ED)) 1) 1)
- )
- )
- (vl-cmdf "CL")
- (vl-cmdf "")
- )
- (vla-delete ENT)
- (setq N (1+ N))
- )
- (setvar "osmode" HOLDOSMODE)
- (command "_.undo" "end")
- (setvar "cmdecho" HOLDECHO)
- (princ)
- )
|