错误:错误的参数类型:consp“90 LR”
编辑:Nevermind。我试着使用(cdr(nth 4(massoc4 300 elist)))。我想cdr函数已经在massoc子函数中使用了,所以在代码的其他部分中不再需要它。谢谢大家的帮助!
顺便问一下,massoc4末尾的4有什么意义吗?我可以用massoc吗? 接得好。我的措辞可能在这方面误导了你,因为我没有查看返回列表的结构。很抱歉
至于函数名,您可以将其命名为massoc,只要确保如果您使用了像MASSOC4这样的递归函数,您也可以将其自身调用的位置重命名。希望这有意义? 是的,这很有道理。谢谢 好的,这里有一个不同的场景,但仍然围绕着同一个主题。我有使用带有属性的块的多重引线。我试图获得这些属性的价值。从帮助文件中,多重引线“块属性文本字符串”的DXF代码为302。当你在一个多重引线上运行(entget(car(entsel)),有两个302值。第一个302值是(302。“LEADER{”),而第二个302值是我真正想要的。我可以使用相同的massoc子函数来提取值,但我认为有一种更好的方法,你们中一些经验更丰富的程序员可以向我指出。 这就是我一直在做的。它再次使用了member和assoc的组合。我假设您只想提取文本字符串,而不是替换它?因为如果你想替换它,我通常在同一个while循环中提取对象ID。
;get the attributes for the block
(setq tmp1 (member (assoc 344 elist) elist)) ;cut out the irrelevant (and duplicated car) earlier codes
(while (setq tmp1 (member (assoc 330 tmp1) tmp1))
(setq attdata (cons (list (cdr (assoc 177 tmp1)) ;attribute number - this becomes important if the text has fields in it
(cdr (assoc 302 tmp1)) ;the attribute string itself
(= (cdr (assoc 101 (entget (cdr (assoc 330 tmp1))))) "Embedded Object") ;single or multiline attribute - this becomes important if you want to know which formatting strings might be present
)
attdata
)
tmp1 (cdr tmp1)
)
);while
;if attributes
(if attdata
....process them
)
我应该补充一点,上面的代码是为在多重引线块中可能有多个属性而编写的。它只适用于一个属性,但也适用于100个属性。如果你知道你只对其中一个感兴趣,你可以把它简化为。
(cdr (assoc 302 (member (assoc 344 elist) elist)))
页:
1
[2]