选矩形框画开门线
如截图中:选择矩形框任意一条边上的点,由此边的中点画直线到对角的端点上。;试用以下程序
(defun c:kmx()
(vl-load-com)
(setq cmd (getvar "cmdecho"))
(setq osm (getvar "osmode"))
(setvar "cmdecho" 0)
(setvar "osmode" 0)
(command "_undo" "be")
(while (setq ssa (ssget ":S" '((0 . "LWPOLYLINE"))))
(setq entx (car (ssnamex ssa)))
(setq obj(vlax-ename->vla-object (cadr entx)))
(setq pae(vlax-curve-getendparam obj))
(if (or (and (= pae 4.0) (= (vlax-curve-isClosed obj) t))
(and (= pae 4.0) (equal (vlax-curve-getstartpoint obj) (vlax-curve-getendpoint obj)))
)
(progn
(setq pt (cadr (last entx)))
(setq pt0(vlax-curve-getclosestpointto obj pt))
(setq par(vlax-curve-getparamatpoint obj pt0))
(setq pai(fix par))
(setq pai-1 (- pai 1.0))
(if (< pai-1 0.0) (setq pai-1 (+ pai-1 pae)))
(setq pai+1 (+ pai 2.0))
(if (> pai+1 pae) (setq pai+1 (- pai+1 pae)))
(setq pmid(vlax-curve-getpointatparam obj (+ pai 0.5)))
(setq pt1 (vlax-curve-getpointatparam obj pai-1))
(setq pt2 (vlax-curve-getpointatparam obj pai+1))
(command "_pline" pt1 pmid pt2 "")
)
(alert "你所选取的不由4点组成的闭合矩形!")
)
)
(command "_undo" "e")
(setvar "osmode" osm)
(setvar "cmdecho" cmd)
(princ)
) 本帖最后由 tfanghui 于 2022-7-19 21:47 编辑
00放飞梦想00 发表于 2020-3-23 16:39
不错代码,开启哪边点哪边很好理解,可考虑加列表选择,同时指定下线型及颜色就更完美了!顶顶顶
望回 ...
楼主看看这个可用吗 http://bbs.mjtd.com/forum.php?mod=viewthread&tid=185869&fromuid=7330607
(出处: 明经CAD社区)
yshf 发表于 2019-6-14 10:19
;试用以下程序
(defun c:kmx()
(vl-load-com)
不错代码,开启哪边点哪边很好理解,可考虑加列表选择,同时指定下线型及颜色就更完美了!顶顶顶
望回复源码 已完成。具体咨询QQ:314328161 这么简单,需要的话,我给你写,算白帮你忙了 1784290342 发表于 2018-10-26 15:26
这么简单,需要的话,我给你写,算白帮你忙了
抽空帮我写个呗:handshake 写出来的发上去啊 没见到上传呀 改为在四边形中点取,更好 yshf 发表于 2019-6-14 10:19
;试用以下程序
(defun c:kmx()
(vl-load-com)
大佬,能不能麻烦改下,封闭空间取点,很少矩形画图的,点取4边边缘生成,
页:
[1]
2