明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 653|回复: 3

[提问] 如何求不限重数内层块A相对于最外层块B的插入点

[复制链接]
发表于 2024-5-16 01:47:22 | 显示全部楼层 |阅读模式
有一个不限重数的多重嵌套块,块名为B ,比如B包含块C、C包含D,D包含块A。  如何求得块A相对于最外层块B定义点的相对插入点?要用什么矩阵转换之类的,实在是不会,恳请高手帮忙,谢谢了!最好是在block中直接算出来,不要在实体中获取,这样速度快。
发表于 2024-5-16 08:52:48 | 显示全部楼层
https://www.lee-mac.com/extractnestedblock.html


leemac  提取嵌套块,层层嵌套实例
发表于 2024-5-17 15:41:00 | 显示全部楼层




  1. (defun blk-in-loop (blkref / res)
  2.   "块嵌套表"
  3.   (setq res nil)
  4.   (if (eq "INSERT" (entity:getdxf blkref 0))
  5.       (progn
  6.   (setq res (cons blkref res))
  7.   (if (setq subblks (vl-remove-if-not
  8.          '(lambda(x)(eq "INSERT" (entity:getdxf x 0)))
  9.          (block:ent-list (entity:getdxf blkref 2))))
  10.       (setq res (cons (mapcar 'blk-in-loop subblks) res)))))
  11.   (reverse res))

  12. (defun blkbase-in-loop (lst-blkloop para1 / res subblks tmp-para)
  13.   "基点坐标嵌套表,para1为基点,旋转角,缩放比例,默认为((0 0)  0 1)"
  14.   (if (null para1)
  15.       (setq para1 '((0 0 0) 0 1.0)))
  16.   (setq res nil)
  17.   (if (eq "INSERT" (entity:getdxf (car lst-blkloop) 0))
  18.       (progn
  19.   (setq res (cons
  20.        (list
  21.         (block:bcs2wcs
  22.          (entity:getdxf (car lst-blkloop) 10)
  23.          (entity:getdxf
  24.           (tblobjname "block" (entity:getdxf (car lst-blkloop) 2))
  25.           10)
  26.          (car para1)
  27.          (cadr para1)
  28.          (caddr para1)
  29.          )
  30.         (+  (cadr para1)
  31.       (entity:getdxf (car lst-blkloop) 50))
  32.         
  33.         (* (entity:getdxf (car lst-blkloop) 41)
  34.            (caddr para1))
  35.         )
  36.        res))
  37.   (entity:putdxf
  38.    (entity:make-circle (caar res) 2)
  39.    62 1)
  40.   (if (setq subblks (cadr lst-blkloop))
  41.       (progn
  42.         (setq tmp-para (car res))
  43.         (setq res (cons (mapcar '(lambda(x)
  44.           (blkbase-in-loop
  45.            x
  46.            tmp-para))
  47.               subblks)
  48.             res))))))
  49.   (reverse res))

  50. (setq blkref(car(entsel)))
  51. (blkbase-in-loop(blk-in-loop blkref)nil)



以上代码由 @lisp函数库 提供支持!  https://atlisp.cn/functionlib.html
请先运行以下代码,再执行上面的代码。
  1. (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))))


 楼主| 发表于 2024-5-18 20:27:48 | 显示全部楼层
谢谢楼上的大师,帮我解决了问题。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-9-28 03:03 , Processed in 0.170800 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表