麻烦优化下打断闭合曲线于两点 的自定义函数
这个函数感觉写的有点绕,麻烦优化下,谢谢!;打断闭合曲线于两点(闭合样条线、多段线,椭圆,圆适用,当然对这几种非闭合曲线也适用)
;(ygs-br@2p(car(entsel"\n请选择闭合线"))(getpoint"\n请点选第一点")(getpoint"\n请点选第二点"))
(defun ygs-br@2p(cls-cur p1 p2)
(setvar 'cmdecho 0)
(setq thisdrawing (vla-get-activedocument
(vlax-get-acad-object)))
(vla-startundomark thisdrawing)
(vla-copy(vlax-ename->vla-object cls-cur))
(if(>(vlax-curve-getparamatpoint cls-cur p1)
(vlax-curve-getparamatpoint cls-cur p2))
(progn
(vl-cmdf "break" (entlast)"non"(vlax-curve-getstartpoint(entlast)) "non" p2)
(vl-cmdf "break" (entlast)"non"(vlax-curve-getendpoint(entlast)) "non" p1)
)
(progn
(vl-cmdf "break"(entlast) "non" (vlax-curve-getstartpoint(entlast)) "non" p1)
(vl-cmdf "break" (entlast) "non" (vlax-curve-getendpoint(entlast)) "non" p2)
)
)
(vl-cmdf "break" cls-cur "non" p1 "non" p2)
(vla-endundomark thisdrawing)
(princ)
)
Enjoy!!! 发表于 2023-3-15 14:12
打断有缺口这个能发一个吗
2楼不是写着吗 (defun br@2p (curve p1 p2)
(if (> (vlax-curve-getparamatpoint curve p1)
(vlax-curve-getparamatpoint curve p2)
)
(vl-cmdf "break" curve "non" p2 "non" p1)
(vl-cmdf "break" curve "non" p1 "non" p2)
)
) xyp1964 发表于 2022-4-4 23:46
(defun br@2p (curve p1 p2)
(if (> (vlax-curve-getparamatpoint curve p1)
(vlax-curve-getparamat ...
感谢院长的回复,您这代码打断后会产生缺口,我是希望闭合线的总长度不变的那种,能否再优化下,谢谢!
[*];;三领打断========
[*];;如果选择打断第二点时右键或空格则打断于点
[*](defun c:sldaduan (/ ent p1 p2 e ang e_lst)
[*](setq e_lst (sysvar '("osmode" "cmdecho")))
[*](setvar "cmdecho" 0)
[*](setvar "OSMODE" 16383)
[*](setq e (car (setq ent (nentsel (slmsg "\n 选择要打断的对象:" "\n 選擇要打斷的對象:")))))
[*](setq ang (+ (e-ang e nil) pi4))
[*](if (setq p1 (getpoint (slmsg "\n 指定打断的第一点 :" "\n 指定打斷的第一點 :")))
[*] (progn
[*] (setq p1 (vlax-curve-getClosestPointTo e p1 nil))
[*] (slslx p1 ang)
[*] )
[*])
[*](if (setq p2 (getpoint (slmsg "\n 指定打断的第二点 , 或打断于点<右键>:" "\n 指定打斷的第二點 , 或打斷於點<右鍵>:")))
[*] (progn
[*] (setq p2 (vlax-curve-getClosestPointTo e p2 nil))
[*] (slslx p2 ang)
[*] )
[*])
[*](if p2
[*] (vl-cmdf ".BREAK" ent "F" p1 p2)
[*] (progn
[*] (vl-cmdf ".BREAK" ent "F" p1 "@")
[*] (vla-put-color (en2obj (entlast)) (atoi (slsjqs)))
[*] )
[*])
[*](redraw)
[*](mapcar 'eval e_lst)
[*](princ)
[*])
guosheyang 发表于 2022-4-5 08:15
感谢院长的回复,您这代码打断后会产生缺口,我是希望闭合线的总长度不变的那种,能否再优化下,谢谢!
打断有缺口这个能发一个吗 285385258@qq.com
页:
[1]