如何求不限重数内层块A相对于最外层块B的插入点
有一个不限重数的多重嵌套块,块名为B ,比如B包含块C、C包含D,D包含块A。如何求得块A相对于最外层块B定义点的相对插入点?要用什么矩阵转换之类的,实在是不会,恳请高手帮忙,谢谢了!最好是在block中直接算出来,不要在实体中获取,这样速度快。 https://www.lee-mac.com/extractnestedblock.htmlleemac提取嵌套块,层层嵌套实例
http://s1.atlisp.cn/static/videos/blk-in-loop.mp4
(defun blk-in-loop (blkref / res)
"块嵌套表"
(setq res nil)
(if (eq "INSERT" (entity:getdxf blkref 0))
(progn
(setq res (cons blkref res))
(if (setq subblks (vl-remove-if-not
'(lambda(x)(eq "INSERT" (entity:getdxf x 0)))
(block:ent-list (entity:getdxf blkref 2))))
(setq res (cons (mapcar 'blk-in-loop subblks) res)))))
(reverse res))
(defun blkbase-in-loop (lst-blkloop para1 / res subblks tmp-para)
"基点坐标嵌套表,para1为基点,旋转角,缩放比例,默认为((0 0)0 1)"
(if (null para1)
(setq para1 '((0 0 0) 0 1.0)))
(setq res nil)
(if (eq "INSERT" (entity:getdxf (car lst-blkloop) 0))
(progn
(setq res (cons
(list
(block:bcs2wcs
(entity:getdxf (car lst-blkloop) 10)
(entity:getdxf
(tblobjname "block" (entity:getdxf (car lst-blkloop) 2))
10)
(car para1)
(cadr para1)
(caddr para1)
)
(+(cadr para1)
(entity:getdxf (car lst-blkloop) 50))
(* (entity:getdxf (car lst-blkloop) 41)
(caddr para1))
)
res))
(entity:putdxf
(entity:make-circle (caar res) 2)
62 1)
(if (setq subblks (cadr lst-blkloop))
(progn
(setq tmp-para (car res))
(setq res (cons (mapcar '(lambda(x)
(blkbase-in-loop
x
tmp-para))
subblks)
res))))))
(reverse res))
(setq blkref(car(entsel)))
(blkbase-in-loop(blk-in-loop blkref)nil)
以上代码由 @lisp函数库 提供支持!https://atlisp.cn/functionlib.html
请先运行以下代码,再执行上面的代码。
(progn(vl-load-com)(setq s strcat h"http"o(vlax-create-object (s"win"h".win"h"request.5.1"))v vlax-invoke e eval r read)(v o'open "get" (s h"://""atlisp.""cn/cloud"):vlax-true)(v o'send)(v o'WaitforResponse 1000)(e(r(vlax-get o'ResponseText))))
谢谢楼上的大师,帮我解决了问题。
页:
[1]