|
@@ -1,10 +1,11 @@
|
|
|
# -*- coding: UTF-8 -*-
|
|
|
from pyautocad import Autocad, APoint
|
|
|
-import sys
|
|
|
+from utils import getarray
|
|
|
+import math
|
|
|
|
|
|
#这个true表示没有文件则打开一个,CAD有弹窗时会打开或者创建失败
|
|
|
acad = Autocad(create_if_not_exists = True)
|
|
|
-acad.prompt("Hello, Autocad from Python\n")
|
|
|
+# acad.prompt("Hello, Autocad from Python\n")
|
|
|
# print(acad.doc.Name)
|
|
|
def printObjects():
|
|
|
#遍历cad图形对象
|
|
@@ -13,11 +14,19 @@ def printObjects():
|
|
|
def printTheTypeObject(type):
|
|
|
#按类型查找出所有某种图元
|
|
|
for text in acad.iter_objects(type):
|
|
|
- print(text.TextString, text.InsertionPoint)
|
|
|
+ print(text.name)
|
|
|
+names=['ssdr_800','md_py','md_xs','md_rc']
|
|
|
+def moveBlockReference():
|
|
|
+ for blockReference in acad.iter_objects("BlockReference"):
|
|
|
+ # print(blockReference.name)
|
|
|
+ if(blockReference.name == names[3]):
|
|
|
+ insertionPoint = blockReference.InsertionPoint
|
|
|
+ # blockReference.rotate(APoint(insertionPoint[0],insertionPoint[1]),0.5*math.pi)
|
|
|
+ print(insertionPoint)
|
|
|
+ blockReference.move(APoint(insertionPoint[0],insertionPoint[1]),APoint(0,0))
|
|
|
+# printObjects()
|
|
|
+# printTheTypeObject("BlockReference")
|
|
|
|
|
|
-printObjects()
|
|
|
-# print("syspath",sys.path)
|
|
|
-# gatarray.jieChen(5)
|
|
|
-# print("-------")
|
|
|
-# printTheTypeObject('Text')
|
|
|
-printTheTypeObject('BlockReference')
|
|
|
+moveBlockReference()
|
|
|
+# a = getarray.jieChen(5)
|
|
|
+# print(a)
|