bcr 发表于 2022-7-6 12:10:52

注释块属性

我是论坛新手,没有编写lisp例程的经验。我有一个例程,它使用块名作为标签来注释块。我想做的是修改这个例程,对块的一个属性进行注释。该属性的标记当前称为“KEY”,但我假设可以对其进行修改,以便可以标记任何属性。
 
如果有人能帮我,我将不胜感激。
 
(定义c:1()
 
(命令“undo”“end”“undo”“begin”)
 
(setvar“luprec”0)
 
 
 
(setq ss(ssget)
(列表
'(0.“插入”)
)))
 
 
(setq bnum(sslength ss))
(setq ent(ssname ss 0))
 
(setq名称(entget ent))
(setq bname(cdr(assoc 2名称)))
 
 
(setvar“orthomode”0)
 
 
 
(setq a(rtos bnum))
 
 
(setq b(strcat bname)(“a”))
 
 
(命令“leader”pause pause“b”)
 
(setvar“orthomode”0)
 
 
(setvar“luprec”2)
 
)

JohnM 发表于 2022-7-6 12:38:16

你能更详细地解释一下吗?我真的不明白你想要实现什么。
你写了张贴的代码吗?
 
下面是发布代码的功能分解。
 

(defun c:1x ( / ss bnum ent bname a b );_need to locolize variables
; (command "undo" "end" "undo" "begin");_this is wrong it shound be
(command "undo""begin");_this marks the beginning of a group to be undon if the undo command is involked
(setvar "luprec" 0);_sets # of zeros after desimal point (this is not needed)
;_prompts user to select a block
(setq ss (ssget
(list
'(0 . "INSERT")
)))
(setq bnum (sslength ss));_# of selected blocks in drawing
(setq ent (ssname ss 0));_gets first item in the selection set
(setq name (entget ent));_# gets block entity info
(setq bname (cdr (assoc 2 name)));_gets block name
(setvar "orthomode" 0);_turns ortho mode off
(setq a (rtos bnum ));_# of selected blocks in the drawing
(setq b (strcat bname "(" a ")"));_puts the block name and the # of occurences of that block together
(command "leader" pause pause "" b "") ;_makse the leader with block anme and number of occurenced of that block in the drawing
(setvar "orthomode" 0);_turns ortho mode off
(setvar "luprec" 2);_sets # of zeros after desimal point (this is not needed)
(command "undo" "end");_this marks the end of a group to be undon if the undo command is involked
(princ)
);_defun

bcr 发表于 2022-7-6 13:09:11

厕所,
 
非常感谢您的回复。它真的帮助我了解了不同的线路的功能。在回答你的问题时。。。
 
1) 不,我没有写例程。一个朋友提供给我的。他是从别人那里得到的。因此,我对这个例程中存在不相关的元素并不感到惊讶。
 
2) 我想做的是修改这个例程,以便生成一个领导者。该引线的文本将是块特定属性的值,而不是块名称的值。
 
谢谢

fixo 发表于 2022-7-6 13:23:22

 
不确定你到底需要什么
试试看
 

(defun c:11 ()

(command "undo" "end" "undo" "begin")
(setvar "luprec" 0)
(setvar "orthomode" 0)
(while
(setq ent (nentsel "\nSelect arribute only (or press Enter to Exit) >>"))
(setq en (car ent)
   elist (entget en)
   attvalue (cdr (assoc 1 elist))
   pt (cadr ent)
   )
(command "leader" pt pause "" attvalue "")
)
(setvar "orthomode" 0)
(setvar "luprec" 2)
(command "undo" "end")
)

 
~'J'~
页: [1]
查看完整版本: 注释块属性