- ;;;;;;;;;;;;非正交矩形画法3种
- (defun c:juxing1(/ pt1 pt2 ent gr grn grp ent2 dist entobj pt4 pt5)
- (princ"\n.........动态任意矩形(命令juxing1)........")
- (vla-startUndoMark mydoc)
- (if(setq pt1(getpoint"\n请输入矩形边第一点:"))
- (if(setq pt2(getpoint pt1"\n请输入矩形边另一点:"))
- (progn
- (entmake (list '(0 . "LINE")(cons 10 pt1)(cons 11 pt2)))
- (setq ent(entlast)flag t)
- (princ"\n请拖动鼠标决定矩形大小,任意键确定...")
- (while(and flag(setq gr(grread t 8) grn(car gr) grp(cadr gr)))
- (cond((= grn 5)
- (if ent2 (vla-delete (vlax-ename->vla-object ent2)))
- (setq dist (distance (setq pt3(apply 'vlax-curve-getclosestpointto (list ent grp)))grp))
- (setq entobj(vla-copy (vlax-ename->vla-object ent)))
- (vla-move entobj (vlax-3d-point pt3)(vlax-3d-point grp))
- (setq pt4(vlax-curve-getstartpoint entobj)
- pt5(vlax-curve-getendpoint entobj)
- )
- (entmake (append(list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity")'(100 . "AcDbPolyline")'(90 . 5))
- (mapcar '(lambda(x)(cons 10 x))(list pt1 pt2 pt5 pt4 pt1)))
- )
- (setq ent2(entlast))
- (vla-delete entobj)
- )
- (t
- (setq flag nil)
- (vla-delete (vlax-ename->vla-object ent))
- )
- )
- )
- )
- )
- )
- (vla-endUndoMark mydoc)
- (princ)
- )
- (defun c:juxing2(/ pt1 pt2 ent gr grn grp ent2 dist entobj pt4 pt5)
- (princ"\n.........三点任意矩形(命令juxing2)........")
- (vla-startUndoMark mydoc)
- (if(setq pt1(getpoint"\n请输入矩形边第一点:"))
- (if(setq pt2(getpoint pt1"\n请输入矩形边另一点:"))
- (progn
- (entmake (list '(0 . "LINE")(cons 10 pt1)(cons 11 pt2)))
- (setq ent(entlast))
- (if (setq pt3(getpoint pt2"\n请输入一点确定矩形方向:"))
- (progn
- (setq dist (distance (setq pt6(apply 'vlax-curve-getclosestpointto (list ent pt3)))pt3))
- (setq entobj(vla-copy (vlax-ename->vla-object ent)))
- (vla-move entobj (vlax-3d-point pt6)(vlax-3d-point pt3))
- (setq pt4(vlax-curve-getstartpoint entobj)
- pt5(vlax-curve-getendpoint entobj)
- )
- (entmake (append(list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity")'(100 . "AcDbPolyline")'(90 . 5))
- (mapcar '(lambda(x)(cons 10 x))(list pt1 pt2 pt5 pt4 pt1)))
- )
- (setq ent2(entlast))
- (vla-delete entobj)
- (vla-delete (vlax-ename->vla-object ent))
- )
- )
- )
- )
- )
- (vla-endUndoMark mydoc)
- (princ)
- )
- (defun c:juxing3()
- (princ"\n.........旋转矩形(命令juxing3)........")
- (setvar 'cmdecho 0)
- (setvar 'orthomode 0)
- (if(setq pt1(getpoint"\n请输入矩形第一点:"))
- (vl-cmdf "rectang" pt1 "r" pause )
- )
- (princ)
- )
|