读取块定义数据
本帖最后由 dcl1214 于 2024-5-26 23:11 编辑同样的代码应该好多同仁写过,先当做笔记发个帖子吧
(defun $kuai-ding-yi$ (km lst / n obj objs i tag-ps)
;读取块定义的属性标记,同时按照Y轴排序
(if (and km (tblsearch "block" km))
(progn
(setq
obj
(vl-catch-all-apply
'vla-item
(list (vla-get-blocks
(vla-get-activedocument (vlax-get-acad-object))
)
km
)
)
)
(if (vl-catch-all-error-p obj)
(setq obj nil)
)
(setq objs nil)
(setq i nil)
(if obj
(vlax-for i obj
(setq n (vl-catch-all-apply 'vla-get-objectname (list i)))
(if (vl-catch-all-error-p n)
(setq n nil)
)
(and n (setq objs (cons i objs)))
)
)
(setq tag-ps
(mapcar
(function
(lambda (a / tag pt)
(setq tag (vl-catch-all-apply 'vla-get-tagstring (LIST a)))
(IF(vl-catch-all-error-p tag)(SETQ tag NIL))
(IF tag(PROGN
(setq pt (vl-catch-all-apply
'vlax-safearray->list
(list (vl-catch-all-apply
'vlax-variant-value
(list (vl-catch-all-apply
'vla-get-insertionpoint
(list a)
)
)
)
)
)
)
(cons tag pt)))
)
)
objs
)
)
(SETQ tag-ps(VL-REMOVE NIL tag-ps))
(setq
tag-ps
(vl-sort tag-ps
(function (lambda (e1 e2)
(> (cadr (cdr e1)) (cadr (cdr e2)))
)
)
)
)
)
)
tag-ps
)
感谢杜总的分享! 感谢昌哥分享:D- 谢谢大佬的分享 感谢杜总的分享!
页:
[1]