本帖最后由 1993063 于 2012-7-6 07:21 编辑
- (defun c:QTR ( / a ang ce cm ent obj op p1 p2 p3 p4 p5 sset)
- (defun *error* (msg)
- (setvar "osmode" a)
- (command "undo" "e")
- (setvar "CMDECHO" CM)
- (setvar "CECOLOR" CE)
- (if (and
- msg
- (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*QUIT*,*EXIT*,"))
- )
- (princ)
- )
- )
- (setq a (getvar "osmode"))
- (setq CM (getvar "CMDECHO"))
- (setq CE (getvar "CECOLOR"))
- (setvar "CMDECHO" 0)
- (SETVAR "CECOLOR" "1")
- (command "undo" "be")
- (cond
- ((vl-cmdf "_.line" (setq p1 (getpoint "\n指定第一点: "))
- (setq p2 (getpoint p1 "\n指定第二点: "))
- ""
- )
- (setq ent (entlast))
- (setq p3 (getpoint "\n点击修剪边: "))
- (setq obj (vlax-ename->vla-object ent))
- (setq op (vlax-curve-getclosestpointto obj p3))
- (setq ang (angle op p3))
- (setq p4 (polar p1 ang 1))
- (setq p5 (polar p2 ang 1))
- (setq sset (ssget "_f" (list p1 p2)))
- (command "_.trim" sset "" "f" p4 p5 "" "")
- (command "_.erase" ent "")
- )
- )
- (setvar "osmode" a)
- (setvar "CMDECHO" CM)
- (setvar "CECOLOR" CE)
- (command "undo" "e")
- (princ)
- )
|