qinhengda 发表于 2024-10-9 10:10:28

ssyfeng 发表于 2024-10-8 15:48
是不是这样:

谢谢大佬,离我预期的接近了,但是我想要的是鼠标输入两点之后绘制中点的构造线,不是点击实体。

黄翔 发表于 2024-10-9 10:49:29

(defun c:11()
(vl-load-com)
(if
(and
    (setq _pt1(getpoint "\n第一点"))
    (setq _pt2(getpoint _pt1 "\n第二点"))
)
(progn
    (setq _mspace (vla-get-modelspace(vla-get-activedocument(vlax-get-acad-object))))
    (setq _pt3 (list (car _pt2) (cadr _pt1)))   
    (setq _pt4 (list (* 0.5 (+ (car _pt1)(car _pt2))) (cadr _pt1)))   
    (vla-addline _mspace (vlax-3d-point _pt1) (vlax-3d-point _pt3))
    (vla-addline _mspace (vlax-3d-point _pt3) (vlax-3d-point _pt2))
    (setq _pt5 (polar _pt4 (* 0.5 pi) 10))   
    (setq _myxline (vla-addXline _mspace (vlax-3d-point _pt5)(vlax-3d-point _pt4)))
)
)
(princ)   
)

qinhengda 发表于 2024-10-9 11:52:00

黄翔 发表于 2024-10-9 10:49


哇大佬,这个可以的了,但,那个辅助的线可以删除吗,即点完两个点,仅保留构造线

黄翔 发表于 2024-10-9 11:54:26

(vla-addline _mspace (vlax-3d-point _pt1) (vlax-3d-point _pt3))
    (vla-addline _mspace (vlax-3d-point _pt3) (vlax-3d-point _pt2))
这两句删掉就可以了啊.

xyp1964 发表于 2024-10-9 13:52:20

(defun c:tt ()
(while (and (setq p1 (getpoint "\n第1点<退出>: "))
            (setq p2 (getpoint p1 "\n第2点<退出>: "))
         )
    (setq p3 (list (car p2) (cadr p1))
          pt (mapcar '(lambda (x y) (* (+ x y) 0.5)) p1 p3)
    )
    (command "Xline" "v" "non" pt "")
)
(princ)
)

C哩C哩 发表于 2024-10-12 10:17:07

这个厉害了啊
页: 1 [2]
查看完整版本: 鼠标任意点击两点绘制水平中点的构造线xline