|
@@ -1,6 +1,6 @@
|
|
|
from pyautocad import Autocad, APoint
|
|
|
from ctypes import cdll
|
|
|
-from utils import getarray,GetAllModule
|
|
|
+from utils import getarray,GetAllModule,getHandler
|
|
|
import os, time, shutil
|
|
|
|
|
|
from pyautocad.cache import Cached
|
|
@@ -20,11 +20,14 @@ doorName = 'ssdr_800'
|
|
|
# 判断文件是否打开
|
|
|
def is_open(filename):
|
|
|
if not os.access(filename, os.F_OK):
|
|
|
+ print("file doesn't exist")
|
|
|
return False # file doesn't exist
|
|
|
h = _sopen(filename, 0, _SH_DENYRW, 0)
|
|
|
if h == 3:
|
|
|
_close(h)
|
|
|
+ print("file is not opened by anyone else")
|
|
|
return False # file is not opened by anyone else
|
|
|
+ print("file is already open")
|
|
|
return True # file is already open
|
|
|
|
|
|
|
|
@@ -37,13 +40,16 @@ def openOriginFile():
|
|
|
time.sleep(10)
|
|
|
print("origin file opened")
|
|
|
def openFile(fileName):
|
|
|
- if(is_open(_rootPath+_originFile)):
|
|
|
- return
|
|
|
+ # if(is_open(_rootPath+_originFile)):
|
|
|
+ # return
|
|
|
|
|
|
print("begin to open file")
|
|
|
os.popen("acad " + fileName)
|
|
|
time.sleep(20)
|
|
|
print("file opened")
|
|
|
+def startAcadAndGetHandler():
|
|
|
+ print("begin to start acad")
|
|
|
+ pass
|
|
|
# 关闭autoCad
|
|
|
def closeAcad():
|
|
|
os.system("taskkill /F /IM acad.exe")
|
|
@@ -109,17 +115,19 @@ def myprocess(m, n):
|
|
|
# copyfile(_rootPath + _originFile, newFileName)
|
|
|
# break
|
|
|
def moveSingleTemplate(fileName,position):
|
|
|
- openFile(fileName)
|
|
|
+ # openFile(fileName)
|
|
|
+ GetAllModule.resetConfUsed()
|
|
|
GetAllModule.moveBlockReference(position)
|
|
|
- time.sleep(5)
|
|
|
+ time.sleep(3)
|
|
|
acad = Autocad(create_if_not_exists = False)
|
|
|
acad.prompt("Hello, Autocad from Python\n")
|
|
|
acad.doc.SaveAs(fileName)
|
|
|
- acad.doc.Shutdown()
|
|
|
- # closeAcad()
|
|
|
+ time.sleep(1)
|
|
|
+ getHandler.backToOrigin()
|
|
|
|
|
|
# openOriginFile()
|
|
|
# tempStorageModules()
|
|
|
# print(is_open(_rootPath+_originFile))
|
|
|
myprocess(4, 3)
|
|
|
# openFile(r"F:\autocad_temp\newfile023.dwg")
|
|
|
+# is_open(r"F:\autocad_temp\origin11.dwg")
|