Explorar el Código

移动及旋转测试

duh hace 7 años
padre
commit
ee980fdf13
Se han modificado 2 ficheros con 29 adiciones y 9 borrados
  1. 18 9
      phxb/utils/GetAllModule.py
  2. 11 0
      phxb/utils/matchWall.py

+ 18 - 9
phxb/utils/GetAllModule.py

@@ -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)

+ 11 - 0
phxb/utils/matchWall.py

@@ -0,0 +1,11 @@
+# 判断能否摆下组件的贴墙边
+def canMathc(wallLength,moduleLengths):
+    moduleTotalLength = 0;
+    for item in moduleLengths:
+        moduleTotalLength = moduleTotalLength + item
+    if(moduleTotalLength <= wallLength):
+        return 1
+    else:
+        return 0
+matchResult = canMathc(3,(1,1,2))
+print(matchResult)