又快又脏,但试试这个:
- (defun c:test (/ #Entlast #Ent #Obj #Length #LType #Value)
- (vl-load-com)
- (or (setq #Entlast (entlast)) (setq #Entlast T))
- (vl-cmdf "_.pline")
- (while (not (zerop (getvar 'cmdactive)))
- (princ "\nSpecify next point: ")
- (vl-cmdf PAUSE)
- ) ;_ while
- (cond
- ((not (eq #Entlast (setq #Ent (entlast))))
- (setq #Obj (vlax-ename->vla-object #Ent)
- #Length (vla-get-length #Obj)
- #LType (strcase (vla-get-linetype #Obj))
- ) ;_ setq
- (cond
- ;; 4-2
- ((eq #LType "4-2") (setq #Value (+ (* (fix (/ (- #Length 4) 6)) 6) 4)))
- ;; 1-5
- ((eq #LType "1-5") (setq #Value (+ (* (fix (/ (- #Length 1) 6)) 6) 1)))
- ;; no match
- (T (alert "No matching Linetypes!"))
- ) ;_ cond
- (and #Value
- (vl-cmdf "_.lengthen" "_total" #Value (list #Ent (getvar 'lastpoint)) "")
- (princ (strcat "\nNew Length: " (vl-princ-to-string #Value)))
- ) ;_ and
- )
- ) ;_ cond
- (princ)
- ) ;_ defun
我让它根据最后拾取的点选择线的终点。
我要回家了,但我肯定晚些时候会回来。 |