好的,李,我已经完全改变了齿轮,我希望你的Lisp程序超级能力可以修复我的Lisp程序。
在编写多行文字插入例程的同时,我还编写了一个非常类似的例程,用于插入具有属性的块。最近在黑板上有很多关于块属性编辑/提取/替换的讨论,所以我想我应该试着用这种方式来组合一些东西。
我想出的惯例本应有效。在用户定义的点插入块,并根据块在图形上的位置,使用适当的字段填充块的“1”(也是唯一)属性。然而,如果该块被移动到另一个位置,那么字段不会更新,因此我必须想出另一个例程来更新所有块。这就是我被困的地方。这是我的代码:
- (defun c:bu(/ Att1Tag ss_blocks NumBlocks Count Ename Attname
- Att_Data Att_txt pt1 pt1x pt1y mtstr
- NewStr New_Attdata)
- (setq Att1Tag "SV")
- (setq ss_blocks (ssget "_X" '((0 . "INSERT")(2 . "SECT_VIEW"))))
- (setq NumBlocks (sslength ss_blocks))
- (setq Count 0)
- (repeat NumBlocks
- (setq Ename (ssname ss_blocks Count))
- (setq Attname Ename)
- (while (= "ATTRIB" (dxf 0 (setq Attname (entnext Attname))))
- (if (= Att1Tag (dxf 2 Attname))
- (progn
- (setq Att_Data (entget Attname))
- (setq Att_txt (cdr (assoc 1 Att_Data)))
- (setq pt1 (assoc 10 Att_Data))
- (setq pt1x (cadr pt))
- (setq pt1y (caddr pt))
- (cond
- ((<= pt1x 5)(setq zoneNUM (strcat "%<[url="file://\\AcVar"]\\AcVar[/url] CustomDP.zone8>%")))
- ((and (<= pt1x 10)(> pt1x 5)(setq zoneNUM (strcat "%<[url="file://\\AcVar"]\\AcVar[/url] CustomDP.zone7>%"))))
- ((and (<= pt1x 15)(> pt1x 10)(setq zoneNUM (strcat "%<[url="file://\\AcVar"]\\AcVar[/url] CustomDP.zone6>%"))))
- ((and (<= pt1x 20)(> pt1x 15)(setq zoneNUM (strcat "%<[url="file://\\AcVar"]\\AcVar[/url] CustomDP.zone5>%"))))
- ((and (<= pt1x 25)(> pt1x 20)(setq zoneNUM (strcat "%<[url="file://\\AcVar"]\\AcVar[/url] CustomDP.zone4>%"))))
- ((and (<= pt1x 30)(> pt1x 25)(setq zoneNUM (strcat "%<[url="file://\\AcVar"]\\AcVar[/url] CustomDP.zone3>%"))))
- ((and (<= pt1x 35)(> pt1x 30)(setq zoneNUM (strcat "%<[url="file://\\AcVar"]\\AcVar[/url] CustomDP.zone2>%"))))
- ((> pt1x 35)(setq zoneNUM (strcat "%<[url="file://\\AcVar"]\\AcVar[/url] CustomDP.zone1>%")))
- )
- (cond
- ((<= pt1y 4.68)(setq zoneLTR "%<[url="file://\\AcVar"]\\AcVar[/url] CustomDP.zonea>%"))
- ((and (<= pt1y 9.34)(> pt1y 4.68)(setq zoneLTR "%<[url="file://\\AcVar"]\\AcVar[/url] CustomDP.zoneb>%")))
- ((and (<= pt1y 14.00)(> pt1y 9.34)(setq zoneLTR "%<[url="file://\\AcVar"]\\AcVar[/url] CustomDP.zonec>%")))
- ((and (<= pt1y 18.66)(> pt1y 14.00)(setq zoneLTR "%<[url="file://\\AcVar"]\\AcVar[/url] CustomDP.zoned>%")))
- ((and (<= pt1y 23.32)(> pt1y 18.66)(setq zoneLTR "%<[url="file://\\AcVar"]\\AcVar[/url] CustomDP.zonee>%")))
- ((> pt1y 23.32)(setq zoneLTR "%<[url="file://\\AcVar"]\\AcVar[/url] CustomDP.zonef>%"))
- )
- (setq mtstr (strcat zoneNUM "-" zoneLTR))
- (setq NewStr mtstr)
- (setq New_Attdata (subst (cons 1 NewStr)(assoc 1 Att_data) Att_Data))
- (entmod New_Attdata)
- (entupd (cdr (assoc 330 Att_Data)))
- ); progn
- ); if
- ); while
- (setq Count (1+ Count))
- ); repeat
- (redraw att1 1)
- (princ)
- )
- (defun dxf (code e)
- (cdr (assoc code (entget e)))
- )
所有名为“SECT_VIEW”的块都有标记“SV”,它们都通过该例程更新,但仅更新到最后一个计算的块计算的值。我的意思是,每个块应该根据它们在图形上的位置具有不同的值,但它们都具有与选择集的最后一个块相关的值(我相信)。
我哪里做错了?
朗尼 |