【已解决】线批量打断申请
本帖最后由 zyxi19 于 2024-5-5 10:15 编辑【已解决】求助大佬编写个批量打断的插键:功能如下:
根据输入打断距离,(可框选,可点选)批量打断交点处的垂直竖线(正交),不打断横线。(或打断横线,不打断竖线,通常默认前者仅仅打断竖线,横线不断),
其中直线类型包括line、pline等常见直线类型,
交点仅仅是线交点,排除线与矩形,或与其他图形交点,
万分感谢大佬出手{:1_23:} zyxi19 发表于 2024-5-3 10:23
谢谢大大提心,补充个图片
(defun c:xdtb_brkgap ( / an ent ints mode p1 p2 ss ss1 vec verts x y)
(defun _break-line (an)
(if (and (setq
ss1 (ssget "f"
verts
'((0 . "*polyline,line")
(-4 . "<not")
(-4 . "&=")
(70 . 1)
(-4 . "not>")
)
)
)
(progn
(ssdel x ss1)
t
)
(> (sslength ss1) 0)
)
(progn
(if (setq ints (xdrx-get-inters x ss1))
(progn
(setq ints
(xdrx-points-sortoncurve x ints)
ints (mapcar 'car ints)
)
(setq ent x)
(mapcar '(lambda (y)
(setq p1 (polar
y
an
(/
#xd-var-global-break-gap-distance
2.0
)
)
p2 (polar
y
(+ an pi)
(/
#xd-var-global-break-gap-distance
2.0
)
)
)
(xdrx-curve-break ent p1 p2)
(setq ent (entlast))
)
ints
)
)
)
)
)
)
(xdrx-begin)
(xd::doc:getdouble
(xdrx-string-multilanguage
"\n打断距离"
"\nBreak Gap Distance"
)
"#xd-var-global-break-gap-distance"
3.5
)
(if (not #xd-var-global-slope-mode)
(setq #xd-var-global-slope-mode "0")
)
(xdrx-initget 0 "0 1")
(if (setq mode
(getkword
(xdrx-string-formatex
(xdrx-string-multilanguage
"\n打断方式[竖线(0)/水平线(1)]<%s>"
"\nInterruption method <%s>"
)
#xd-var-global-slope-mode
)
)
)
(setq #xd-var-global-slope-mode mode)
)
(if (setq ss (xdrx-ssget
(xdrx-string-multilanguage
"\n选择要处理的线<退出>:"
"\nSelect lines to process <Exit>:"
)
'((0 . "*polyline,line")
(-4 . "<not")
(-4 . "&=")
(70 . 1)
(-4 . "not>")
)
)
)
(progn
(xdrx-begin)
(xdrx-document-safezoom ss)
(mapcar '(lambda (x)
(if (or (xdrx-object-iskindof x "line")
(and (xdrx-object-iskindof x "*polyline")
(= (xdrx-getpropertyvalue x "numverts") 2)
(xdrx-polyline-isonlylines x)
)
)
(progn
(setq verts (xdrx-getpropertyvalue x "vertices")
vec (xdrx-vector-normalize
(mapcar '- (last verts) (car verts))
)
)
(if (= #xd-var-global-slope-mode "0")
(progn
(if (xdrx-vector-isparallelto '(0 1 0) vec)
(_break-line (/ pi 2.0))
)
)
(progn
(if (xdrx-vector-isparallelto '(1 0 0) vec)
(_break-line 0.0)
)
)
)
)
)
)
(xdrx-ss->ents ss)
)
(xdrx-end)
)
)
(princ)
)
提交一个前后的对比DWG图吧 谢谢大大提心,补充个图片
https://i.hd-r.cn/078f7849d67b14cf15988ac2f975ef70.jpg
本帖最后由 zyxi19 于 2024-5-4 11:56 编辑
感谢大大百忙之中帮忙制作{:1_23:},目前有个问题,前面没有说清楚,能不能只打断十字相交的地方,圆圈处不打断,仅仅打断相交且为十字相交的情况,如下图https://i.hd-r.cn/ddddbb0567cc89340ff73c394c8b6d86.jpg zyxi19 发表于 2024-5-4 10:21
感谢大大百忙之中帮忙制作,目前有个问题,前面没有说清楚,能不能只打断十字相交的地方,圆圈处不打断,仅 ...
试下下面的代码, 如果可以了,请编辑下主题贴,在前面填上【已解决】,谢谢
(defun c:xdtb_brkgap ( / verts1 an ent ints mode p1 p2 ss ss1 vec verts x y)
(defun _break-line (ent an)
(if (and (setq
ss1 (ssget "f"
verts
'((0 . "*polyline,line")
(-4 . "<not")
(-4 . "&=")
(70 . 1)
(-4 . "not>")
)
)
)
(progn
(ssdel x ss1)
t
)
(> (sslength ss1) 0)
)
(progn
(mapcar '(lambda (x)
(setq verts1 (xdrx-getpropertyvalue x "vertices"))
(if (and (setq ints (xdrx-get-inters ent x))
(setq ints (vl-remove-if
'(lambda (y)
(or (member y verts1)
(member y verts))
)
ints
)
)
(> (length ints) 0)
)
(progn
(setq ints
(xdrx-points-sortoncurve ent ints)
ints (mapcar 'car ints)
)
(mapcar '(lambda (y)
(setq p1 (polar
y
an
(/
#xd-var-global-break-gap-distance
2.0
)
)
p2 (polar
y
(+ an pi)
(/
#xd-var-global-break-gap-distance
2.0
)
)
)
(xdrx-curve-break ent p1 p2)
(setq ent (entlast))
)
ints
)
)
)
)
(xdrx-ss->ents ss1)
)
)
)
)
(xdrx-begin)
(xd::doc:getdouble
(xdrx-string-multilanguage
"\n打断距离"
"\nBreak Gap Distance"
)
"#xd-var-global-break-gap-distance"
3.5
)
(if (not #xd-var-global-slope-mode)
(setq #xd-var-global-slope-mode "0")
)
(xdrx-initget 0 "0 1")
(if (setq mode
(getkword
(xdrx-string-formatex
(xdrx-string-multilanguage
"\n打断方式[竖线(0)/水平线(1)]<%s>"
"\nInterruption method <%s>"
)
#xd-var-global-slope-mode
)
)
)
(setq #xd-var-global-slope-mode mode)
)
(if (setq ss (xdrx-ssget
(xdrx-string-multilanguage
"\n选择要处理的线<退出>:"
"\nSelect lines to process <Exit>:"
)
'((0 . "*polyline,line")
(-4 . "<not")
(-4 . "&=")
(70 . 1)
(-4 . "not>")
)
)
)
(progn
(xdrx-begin)
(xdrx-document-safezoom ss)
(mapcar '(lambda (x)
(if (or (xdrx-object-iskindof x "line")
(and (xdrx-object-iskindof x "*polyline")
(= (xdrx-getpropertyvalue x "numverts") 2)
(xdrx-polyline-isonlylines x)
)
)
(progn
(setq verts (xdrx-getpropertyvalue x "vertices")
vec (xdrx-vector-normalize
(mapcar '- (last verts) (car verts))
)
)
(if (= #xd-var-global-slope-mode "0")
(progn
(if (xdrx-vector-isparallelto '(0 1 0) vec)
(_break-line x (/ pi 2.0))
)
)
(progn
(if (xdrx-vector-isparallelto '(1 0 0) vec)
(_break-line x 0.0)
)
)
)
)
)
)
(xdrx-ss->ents ss)
)
(xdrx-end)
)
)
(princ)
)
完美解决,再次感谢大大, XDSoft 发表于 2024-5-4 14:57
试下下面的代码, 如果可以了,请编辑下主题贴,在前面填上【已解决】,谢谢
大大发现个bug,测试文件中迂回多段线无法剪断,另外大大方便的话加入个容差(竖线与垂直竖线30°也可以打断,横线同样。)
建议大大给个码,请大大喝杯奶茶啥的{:1_7:}
本帖最后由 zyxi19 于 2024-6-2 11:47 编辑
测试文件
大大能给个码,请你喝杯奶茶啥的{:1_12:} 这个画施工图很有用。 有大佬能帮忙解决的吗,求求大佬出手了 66666{:1_23:}{:1_23:}{:1_23:}
页:
[1]