Pycad 对属性块简单处理,方便调用
class BlockAtt:
def __init__(self,blockref) :
self.blockref = blockref
self.attdict={}
for attid in self.blockref.AttributeCollection:
att = attid.GetObject(OpenMode.ForWrite)
setattr(self,att.Tag,att)
def SetTextString(self,Tag,TextString):
getattr(self,Tag).TextString = TextString
def SetHeight(self,Tag,height):
getattr(self,Tag).Height= height
def GetTextString(self,Tag):
return getattr(self,Tag).TextString
def ChangeTagName(self,Tag,NewTagName):
if hasattr(self, NewTagName):
print("att has tag {0}".format(NewTagName))
else:
getattr(self, Tag).Tag=NewTagName
本帖最后由 枫叶棋语 于 2023-6-3 18:43 编辑
blockatt=BlockAtt(block)
#假设有属性Tag="a",属性值TextString="atext"可以直接获取,修改
textstring = blockatt.GetTextString("a")
#也可以调用内部字典进行查询
兄弟你对属性块比较熟悉吗 664571221 发表于 2023-6-3 20:14
兄弟你对属性块比较熟悉吗
初学,熟悉谈不上 Pycad怎么个玩法? PYCAD环境怎么配置?
页:
[1]