h2295 发表于 2024-4-30 11:07:54

快速建块(属性块)

请问怎么将选中的多个text快速建成一个属性块,即先将选中的text定义属性,然后合并成一个block。这是从别的帖子找到的可以将单个文本转为属性,怎么修改可以一次转多个文本然后将其合并成一个block。


;;; ;; 文本转属性txtatt Define the top-level function for the command "txtatt"
(defun c:tt1 (/ ent)
(if (setq ent (entsel "\nSelect text entity: ")); Prompt user to select an entity
    (txt2att (car ent)) ; Call the core function with the selected entity
    (prompt "No entity was selected.")
)
)
;;; Define the core function that converts a text entity to an attribute definition
(defun txt2att (ent / entdxf newdxf malst tem)
(setq entdxf (entget ent)
      newdxf '((0 . "ATTDEF"))
      newdxf (append
               newdxf
               (list
                   (cons 1 (cdr (assoc 1 entdxf)))
                   (cons 2 (cdr (assoc 1 entdxf)))
                   (cons 3 (cdr (assoc 1 entdxf)))
                   (cons 70 0)
               )
               )
      malst(list 7 8 10 11 39 40 41 50 51 62 71 72 73)
)
(foreach mai malst
    (setq tem (assoc mai entdxf))
    (if (/= tem nil)
      (setq newdxf (append newdxf (list tem)))
    )
)
(entdel ent)
(entmake newdxf)
)


页: [1]
查看完整版本: 快速建块(属性块)