[pycad]抛砖、续貂之cad二开零基础自用:块改色
# 枫叶版pycad 感谢飞狐,山人,枫叶,闻人南的示例
#让pycad不放弃每一个打螺丝人
@Command()
def changeColor25(doc): #普通简单块改色
with dbtrans(doc) as tr:
ss = ssget_x(filters=(0, 'insert') )
if not ss.ok:
return
idSS = tuple(ss)
iSet1 = set()
for Entobjid in idSS:
btref = tr.getobject(Entobjid, acdb.OpenMode.ForWrite)
btrecid = btref.BlockTableRecord
iSet1.add(btrecid)
btrecs =
for btrec in btrecs:
for Entobjid in btrec:
ent = tr.getobject(Entobjid, acdb.OpenMode.ForWrite)
ent.ColorIndex = 0
blockidSS = btrec.GetBlockReferenceIds(True, False)
for blockid in blockidSS:
blockref = tr.getobject(blockid, acdb.OpenMode.ForWrite)
blockref.ColorIndex = 3
tr.flush(blockref) 谢谢楼主分享!
页:
[1]