怎么实现点击封闭图形内部,自动形成开洞线
点击左边的封闭图形,形成开洞符号,最好能检测所点击的图形是否为封闭的图形 本帖最后由 qazxswk 于 2023-10-30 00:09 编辑a405692168 发表于 2023-10-26 20:53
谢谢,大神这个好用,有空的时候,能增加个功能:自动把开洞线固定到"开洞线"图层上吗?
(defun c:11(/entpt p1 p2 p3 p0 len len1 minpoint maxpoint)
(if (= (tblobjname "layer" "开洞线") nil)
(entmake (list'(0 . "layer")'(100 . "AcDbSymbolTableRecord") '(100 . "AcDbLayerTableRecord")
(cons 2 "开洞线") '(70 . 0) '(62 . 8)
)))
(while
(setq pt (getpoint "\n在闭合区域拾取一点<退出>:"))
(vl-cmdf "-boundary" pt "")
(setq ent (entlast))
(vla-getboundingbox (vlax-ename->vla-object ent) 'minpoint 'maxpoint) ;获得包围盒
(setq p1(vlax-safearray->list minpoint) p3(vlax-safearray->list maxpoint)) ;盒最小与最大点
(entdel ent)
(setq p2 (list (car p1)(cadr p3)))
(setq len (distance p1 p2))
(setq len1 (distance p3 p2))
(if (< len len1)
(setq p0 (polar p1 (/ pi 3)(* len 0.8)))
(setq p0 (polar p1 (/ pi 2.2)(* len 0.8)))
)
(entmake (list'(0 . "LWPOLYLINE")'(100 . "AcDbEntity")'(100 . "AcDbPolyline")(cons 8 "开洞线")
(cons 90 3) (cons 10 p1) (cons 10 p0) (cons 10 p3) ))
)
(princ)) 我的不需要配合任何工具箱的。可以试试
(defun c:11(/entpt p1 p2 p3 p0 len len1 minpoint maxpoint)
(while
(setq pt (getpoint "\n在闭合区域拾取一点<退出>:"))
(vl-cmdf "-boundary" pt "")
(setq ent (entlast))
(vla-getboundingbox (vlax-ename->vla-object ent) 'minpoint 'maxpoint) ;获得包围盒
(setq p1(vlax-safearray->list minpoint) p3(vlax-safearray->list maxpoint)) ;盒最小与最大点
(entdel ent)
(setq p2 (list (car p1)(cadr p3)))
(setq len (distance p1 p2))
(setq len1 (distance p3 p2))
(if (< len len1)
(setq p0 (polar p1 (/ pi 3)(* len 0.8)))
(setq p0 (polar p1 (/ pi 2.2)(* len 0.8)))
)
(entmake (list'(0 . "LWPOLYLINE")'(100 . "AcDbEntity")'(100 . "AcDbPolyline")(cons 62 8)
(cons 90 3) (cons 10 p1) (cons 10 p0) (cons 10 p3) ))
)
(princ))
(defun c:tt ()
"tt(开洞线)"
(xyp-MkLaCo "开洞线" 8)
(while (setq p0 (getpoint "\n选择内部a点<退出>: "))
(bpoly p0)
(setq s1(entlast)
ptn (xyp-9ptList s1)
p1(car ptn)
p7(nth 6 ptn)
p9(last ptn)
p7a (polar p7 (* pi 1.75) (* (distance p1 p9) 0.1))
s2(xyp-Pline (list (car ptn) p7a (last ptn)) nil)
)
(entdel s1)
)
(princ)
)
1、选择内部一点;
2、调用BOUNDY函数建立封闭线条;
3、取得最后的实体;
4、取得最后实体的点集;
5、判断是否是矩形;
6、求出左下和右上点及计算折线点;
7、根据计算出的坐标点画出洞口。 这个功能不错,我用画窗户的开启线 对象点画线比较快,点区域会慢吧 计算折线点,我就缺少这个折线点的公式了,不然我也能写出来了! 同求,有这样的程序不? BOUNDY函数怎么用 同求,有哪个大神可以帮忙写下这个源码
论坛有源码,可自助搜索
页:
[1]
2