求问如何在一条线段两侧各加一段线
已知线段的两侧端点座标,偏移0.5,再画一段长2的线。感谢
(defun c:tt (/ p1 p2 fun)
(setq p1 (getpoint "\np1:"))
(setq p2 (getpoint "\np2:"))
(setq fun (lambda (x y) (entmake (list '(0 . "line") (cons 10 x) (cons 11 y)))))
(fun (polar p1 (angle p1 p2) 0.5) (polar p1 (angle p1 p2) 2.5))
(fun (polar p2 (angle p2 p1) 0.5) (polar p2 (angle p2 p1) 2.5))
(princ)
) 本帖最后由 `中微子 于 2024-5-31 00:48 编辑
很简单.看是不是你要的.
随时修改.也可以你自己改.
看不是不你要的!
用polar函数确定点 试试
;(hs (trans (getpoint"\n指定第一点:") 1 0) (trans (getpoint"\n指定第二点:") 1 0) 0.5 2)
(defun hs (p1 p2 off dis / norm jl x1 x2 x11 x22)
(setq norm (mapcar '- p2 p1))
(setq jl (distance p1 p2))
(setq x1 (mapcar '+p1(trans (list 0 0 off) norm 0) ))
(setq x2 (mapcar '+p1(trans (list 0 0 (+ off dis)) norm 0) ))
(setq x11 (mapcar '+p1(trans (list 0 0 (- jl off dis)) norm 0)))
(setq x22 (mapcar '+p1(trans (list 0 0 (- jl off)) norm 0)))
(entmake (list '(0 . "line") (cons 10 x1) (cons 11 x2)))
(entmake (list '(0 . "line") (cons 10 x11) (cons 11 x22)))
(princ)
) pzweng 发表于 2024-5-31 10:57
(defun c:tt (/ p1 p2 fun)
(setq p1 (getpoint "\np1:"))
(setq p2 (getpoint "\np2:"))
版主学习了,这个FUN没看懂! pzweng 发表于 2024-5-31 10:57
(defun c:tt (/ p1 p2 fun)
(setq p1 (getpoint "\np1:"))
(setq p2 (getpoint "\np2:"))
这个写法,很牛逼,学习了。
页:
[1]