蒹葭_Keirll 发表于 2012-5-7 09:15:12

井字梁打断程序,求修改

如果要打断的梁线是虚线,可能会出错,求修改

(defun c:BeamBreak1(/ uc obj pt ax ay bx by cx cy dx dy a b c d ab bc cd da l1 l2 l3 l4)
(setq uc (getvar "ucsorg"));换成世界坐标
(setq pt(getpoint "\nselect a point:"))
(while pt
    (command "-boundary" pt "")
    (setq obj (entget (entlast)))
    (setq ax (- (cadr (nth 14 obj)) (car uc)))
    (setq ay (- (caddr (nth 14 obj)) (cadr uc)))
    (setq bx (- (cadr (nth 18 obj)) (car uc)))
    (setq by (- (caddr (nth 18 obj)) (cadr uc)))
    (setq cx (- (cadr (nth 22 obj)) (car uc)))
    (setq cy (- (caddr (nth 22 obj)) (cadr uc)))
    (setq dx (- (cadr (nth 26 obj)) (car uc)))
    (setq dy (- (caddr (nth 26 obj)) (cadr uc)))
    (setq a (list ax ay))
    (setq b (list bx by))
    (setq c (list cx cy))
    (setq d (list dx dy))
    (setq ab (list (/ (+ ax bx) 2.0) (/ (+ ay by) 2.0)))
    (setq bc (list (/ (+ bx cx) 2.0) (/ (+ by cy) 2.0)))
    (setq cd (list (/ (+ cx dx) 2.0) (/ (+ cy dy) 2.0)))
    (setq da (list (/ (+ dx ax) 2.0) (/ (+ dy ay) 2.0)))
    (command "erase" "l" "")
    ;梁的打断
    (setq l1 (nentselp cd))
    (setq l2 (nentselp ab))
    (setq l3 (nentselp bc))
    (setq l4 (nentselp da))
    (command "break" l1 "f" c d)
    (command "break" l2 "f" a b)
    (command "break" l3 "f" c b)
    (command "break" l4 "f" d a)
      
(setq pt(getpoint "\nselect a point:"))
)
)



http://bbs.mjtd.com/xwb/images/bgimg/icon_logo.png 该贴已经同步到 蒹葭_Keirll的微博

wowan1314 发表于 2012-5-7 09:56:05

本帖最后由 wowan1314 于 2012-5-7 11:15 编辑

按他的算法是有这个弊端啊! 他是通过一点来获取图元,如果此点刚好是虚线部分的可能就选不到图元了。
我尝试通过设置线型的全局比例因子来更新虚线部分。但是失败了。
(SETVAR "LTSCALE" 0.0001)
(COMMAND "._REGEN");在程序中未重新生成。
另好像有个帖子是说智能剪切的,可找找看是否满足要求。

帮顶,期待高手出现。

shute05 发表于 2012-5-7 15:57:24

你的线型是虚线时 ,有时会选不到物体,,将线型改为直线,,最后再改回来

蒹葭_Keirll 发表于 2012-5-7 20:17:18

我想通过程序改线型,但是没成功。数据库里线形是在(6 . “XXX”)里的,但如果一条线是bylayer的话就没有这项了
页: [1]
查看完整版本: 井字梁打断程序,求修改