testopen.py 1006 B

1234567891011121314151617181920212223242526
  1. # coding=utf-8
  2. from ctypes import *
  3. from pyautocad import Autocad,APoint
  4. import win32api
  5. import os
  6. def openTxt(fileName):
  7. win32api.ShellExecute(0, 'open', r'C:\Program Files (x86)\Notepad++\notepad++.exe', fileName,'',1)
  8. def openTxt2(handler,fileName):
  9. print(handler)
  10. handler=win32api.ShellExecute(handler, 'open', r'C:\Program Files\TortoiseGit\bin\notepad2.exe', fileName,'',1)
  11. print(handler)
  12. def openbyApi():
  13. win32api.ShellExecute(0, 'open', r'D:\tools\autocadinstall\AutoCAD 2016\acad.exe', r'F:\autocad_temp\newfile032.dwg','',1)
  14. def closeAcad():
  15. os.system("taskkill /F /IM acad.exe")
  16. def shellDllOpen(file):
  17. shelldll = WinDLL("C:/Windows/System32/shell32.dll")
  18. shelldll.ShellExecuteW(None, 'open', file, '', '', 1)
  19. def autoOpen(file):
  20. acad = Autocad(create_if_not_exists = True)
  21. p1 = APoint(0,0)
  22. acad.model.InsertBlock(p1,file,1,1,1,0)
  23. # openbyApi()
  24. # shellDllOpen(r"e:/jstat.txt")
  25. # shellDllOpen(r"e:/jstat.txt")
  26. # autoOpen( r'F:\autocad_temp\origin.dwg')