求助大神:已知图元名,判断该图元是否在某个块内,如果在块内,获取父块名称
如题,求助!求助!求助! 遍历所有块,然后查找到了返回图块名 jun353835273 发表于 2020-12-2 11:48遍历所有块,然后查找到了返回图块名
谢谢你啊,我试试 ;;; 取嵌套块
(DEFUN C:Block-GetNestBlk (/ entSS nestlist nestlen NestBlkName mSPACE pt)
;; 选择对象
(SETQ entSS (ENTSEL "\n ---- 选择嵌套块:"))
(IF (NULL entSS)
(EXIT)
)
;; 提取由内向外嵌套表,计算嵌套长度【1,即无嵌套关系,0,非块】
(SETQ nestlist (NTH 3 (NENTSELP (CADR entSS))))
(SETQ nestlen (LENGTH nestlist))
;;; (PRINC "\n ---- nestlist:")
;;; (PRINC nestlist)
;; 检查选择是否为块,且点选的为嵌套块;插入块
(IF (AND (= (CDR (ASSOC 0 (ENTGET (CAR entSS)))) "INSERT")
(> nestlen 1)
)
(PROGN
;; 提取嵌套块名
(SETQ NestBlkName (CDR (ASSOC 2 (ENTGET (CAR nestlist)))))
(PRINC "\n ---- 嵌套块名:")
(PRINC NestBlkName)
;; 拾取点并插入块
(SETQ pt (GETPOINT "\n ---- 指定块插入点:"))
(SETQ mSPACE (VLA-GET-MODELSPACE (VLA-GET-ACTIVEDOCUMENT (VLAX-GET-ACAD-OBJECT))))
(VLA-INSERTBLOCK mSPACE (VLAX-3D-POINT pt) NestBlkName 1 1 1 0)
)
(ALERT "选择的图元不是块,或为非嵌套块")
)
(PRINC)
)
页:
[1]