普通字转属性字的代码
看了下论坛上有属性字转普通字的,没有普通字转属性字的lsp源码,大佬们能发一个吗? ;;; 批量文本转属性定义 txtat Define the top-level function for the command "txtatt"(defun c:txtatt (/ ss ent)
(if (setq ss (ssget "_:L" '((0 . "TEXT,MTEXT"))))
(progn
(setq i 0)
(repeat (sslength ss)
(setq ent (ssname ss i))
(txt2att ent)
(setq i (1+ i))
)
)
(if (setq ent (entsel "\nSelect text entity: "))
(txt2att (car ent))
(prompt "No entity was selected.")
)
)
(princ)
)
;;; 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)
)
本帖最后由 wzg356 于 2023-9-27 10:08 编辑
;;; 文本转属性
(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 (assoc mai entdxf))
)
)
)
)
(entdel ent)
(entmake newdxf)
) 本帖最后由 wide 于 2023-9-27 10:32 编辑
谢谢二楼的大佬。 ;;; ;; 文本转属性txtatt Define the top-level function for the command "txtatt"
(defun c:txtatt (/ 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)
)
moshouhot 发表于 2024-4-16 17:35
;;; ;; 文本转属性txtatt Define the top-level function for the command "txtatt"
(defun c:txtatt (/...
请问可以将多个文本转为一个属性块的多个属性吗? h2295 发表于 2024-4-30 09:15
请问可以将多个文本转为一个属性块的多个属性吗?
问我不如问chatgpt moshouhot 发表于 2024-4-30 14:10
问我不如问chatgpt
问了3.5的,他也不知道 moshouhot 发表于 2024-4-30 15:21
可以再加个将转好后的属性合并成一个block吗,我刚试了没成功:lol moshouhot 发表于 2024-4-30 15:21
转换后的对象会偏移怎么处理:(
页:
[1]
2