GetAllModule.py 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. # -*- coding: UTF-8 -*-
  2. from pyautocad import Autocad, APoint
  3. from utils import getarray
  4. import math
  5. #这个true表示没有文件则打开一个,CAD有弹窗时会打开或者创建失败
  6. acad = Autocad(create_if_not_exists = True)
  7. # acad.prompt("Hello, Autocad from Python\n")
  8. # print(acad.doc.Name)
  9. def printObjects():
  10. #遍历cad图形对象
  11. for obj in acad.iter_objects():
  12. print(obj.ObjectName)
  13. def printTheTypeObject(type):
  14. #按类型查找出所有某种图元
  15. for text in acad.iter_objects(type):
  16. print(text.name)
  17. names=['ssdr_800','md_py','md_xs','md_rc']
  18. def moveBlockReference():
  19. for blockReference in acad.iter_objects("BlockReference"):
  20. # print(blockReference.name)
  21. if(blockReference.name == names[3]):
  22. insertionPoint = blockReference.InsertionPoint
  23. blockReference.rotate(APoint(insertionPoint[0],insertionPoint[1]),-0.5*math.pi)
  24. print(insertionPoint)
  25. # blockReference.move(APoint(insertionPoint[0],insertionPoint[1]),APoint(0,0))
  26. # printObjects()
  27. # printTheTypeObject("BlockReference")
  28. moveBlockReference()
  29. # a = getarray.jieChen(5)
  30. # print(a)