[Python] 纯文本查看 复制代码 from pyautocad import Autocad
import pythoncom
def run(path):
pythoncom.CoInitialize()
acad = Autocad(create_if_not_exists=True)
acad.Application.Documents.Open(path)
acad.ActiveDocument.Layers.Add("HIT_Layer")
if acad:
blocks = acad.doc.Blocks
blocks = acad.best_interface(blocks)
for block in blocks:
print(block.Name)
count = block.Count
if"*Model Space"==block.Name:
for i in range(count):
item = block.Item(i)
print(item.EntityName)
print(dir(item))
elif "*Paper_Space"==block.Name: # 布局1
pass
elif "*Paper_Space0"==block.Name:#布局2
pass
return
if __name__=='__main__':
run(r'G:\桌面\批量打印\测试.dwg')
|