鼠标点选P1\P2\P3然后就画图如下图所示的图形。65跟150是固定的。麻烦大神给搞个编码
本帖最后由 chq168168 于 2023-8-14 15:11 编辑鼠标点选P1\P2\P3然后就画图如下图所示的图形。65跟150是固定的。麻烦大神给搞个编码 (defun c:tt (/ p1 p2 p3 e e1 e11 e2 e22)
(setq p1 (getpoint "\n指定第一点"))
(if (not p1)
(vl-exit-with-value 0)
)
(setq p2 (getpoint p1 "\n指定第一点"))
(if (not p2)
(vl-exit-with-value 0)
)
(setq p3 (getpoint p2 "\n指定第一点"))
(if (not p3)
(vl-exit-with-value 0)
)
(setq e (Make-LWPOLYLINE (list p1 p2 p3)))
(vla-Offset (vlax-ename->vla-object e) -65)
(setq e1 (entlast))
(vla-Offset (vlax-ename->vla-object e) 65)
(setq e2 (entlast))
(if (< (vlax-curve-getDistAtPoint e1 (vlax-curve-getEndPoint e1))
(vlax-curve-getDistAtPoint e2 (vlax-curve-getEndPoint e2))
)
(entdel e2)
(progn (entdel e1) (setq e1 e2))
)
(vla-Offset (vlax-ename->vla-object e) 150)
(setq e11 (entlast))
(vla-Offset (vlax-ename->vla-object e) -150)
(setq e22 (entlast))
(if (< (vlax-curve-getDistAtPoint e11 (vlax-curve-getEndPoint e11))
(vlax-curve-getDistAtPoint e22 (vlax-curve-getEndPoint e22))
)
(entdel e22)
(progn (entdel e11) (setq e11 e22))
)
(Make-LWPOLYLINE
(list (vlax-curve-getStartPoint e) (vlax-curve-getStartPoint e11))
)
(Make-LWPOLYLINE
(list (vlax-curve-getEndPoint e) (vlax-curve-getEndPoint e11))
)
)
;;167.3 [功能] Entmake点表生成多段线
(defun Make-LWPOLYLINE (lst / PT)
(entmakeX
(append
(list '(0 . "LWPOLYLINE")
'(100 . "AcDbEntity")
'(100 . "AcDbPolyline")
(cons 90 (length lst))
)
(mapcar '(lambda (pt) (cons 10 pt)) lst)
)
)
) (setq p1 (getpoint "\n输入沾灰面P1点"))
(setq p2 (getpoint "\n输入沾灰面P2点"))
(setq p3 (getpoint "\n输入沾灰面P3点"))
(setq alf1 (angle p1 p2))
(setq alf2 (angle p3 p2))
(setq pm (polar p1 (+ alf1(* 1.5 pi))65))
(setq p6 (polar p1 (+ alf1(* 1.5 pi))150))
(setq pn (polar p3 (+ alf2(* 0.5 pi))65))
(setq p4 (polar p3 (+ alf2(* 0.5 pi))150))
(setq pp (inters pm (polar pm (angle p1 p2) 1) pn (polar pn (angle p2 p3) 1) nil))
(setq p5 (inters p6 (polar p6 (angle p1 p2) 1) p4 (polar p4 (angle p2 p3) 1) nil))
(command-s "pline" p1 p2 p3 p4 P5p6 "c")
(command-s "pline" pmPP pn"")
(command-S "LINE" P2 P5 "")
liuhe 发表于 2023-8-14 15:42
谢谢大哥,你这个代码能画出来,就是看不懂,我就是初学者,刚开始编写个代码画个图试试,这不遇到了不会求点了。下边是我写的代码,画出来为什么有时候有个边是75,搞不明白。 chq168168 发表于 2023-8-14 15:49
liuhe 发表于 2023-8-14 15:42
(setq p4 (polar p3 (+ alf2(* 0.5 pi))150))
(setq old(getvar 'osmode ))
(setvar 'osmode 0);;;;关闭捕捉
(setq pp (inters pm (polar pm (angle p1 p2) 100) pn (polar pn (angle p2 p3) 100) nil))
(setq p5 (inters p6 (polar p6 (angle p1 p2) 100) p4 (polar p4 (angle p2 p3) 100) nil))
(command-s "pline" p1 p2 p3 p4 P5p6 "c")
(command-s "pline" pmPP pn"")
(command-S "LINE" P2 P5 "")
(setvar 'osmode old) 神一样的问题。。。 llsheng_73 发表于 2023-8-14 14:44
神一样的问题。。。
大哥有图片的不知道为什么不显示:L,我又重新传了一个 上源码吧,不知道你要问啥 (setq pp (inters pm (polar pm (angle p1 p2) 1) pn (polar pn (angle p2 p3) 1) nil))
同理求p5 p6p5与p1p2平行,angle可以求出,有polar可以求出p6p5上一点p51;同理可以求出p4p5上一点p52。
于是(inerts p6 p51 p4 p52 nil)求出p5 自贡黄明儒 发表于 2023-8-14 15:09
p6p5与p1p2平行,angle可以求出,有polar可以求出p6p5上一点p51;同理可以求出p4p5上一点p52。
于是(inerts ...
大哥给个碼学习下,自己学着写这个图形的时候开在P5点了 start4444 发表于 2023-8-14 15:04
(setq pp (inters pm (polar pm (angle p1 p2) 1) pn (polar pn (angle p2 p3) 1) nil))
同理求p5
谢谢大神,搞出来这两个点了