Я пытаюсь сохранить и закрыть приложение AutoCAD. Я пытался использовать .Quit()
, но не получилось.
from comtypes import COMError
from comtypes.client import CreateObject, GetActiveObject
def main():
# Capture opened AutoCAD
try:
acad = GetActiveObject("AutoCAD.Application")
# Open new AutoCAD instance
except (OSError, COMError):
acad = CreateObject("AutoCAD.Application", dynamic=True)
# Path to dwg file
filepath = r"C:\test.dwg" # Replace it with the actual drawing path
doc = acad.Documents.Open(filepath)
load_lisp = '(load "C:/DemoExtracao.fas") ' # Notice that the last SPACE is equivalent to
doc.SendCommand(load_lisp)
execute_lisp = "(DEMO) "
doc.SendCommand(execute_lisp)
doc.Quit() # This line doesn't work
# Início da aplicação principal
if __name__ == "__main__":
main()
Как сохранить и закрыть приложение AutoCAD?
win32com
: Сохранение файлов AutoCAD (.dwg) с помощью Python. В ответе также есть ссылки на документацию по программированию AutoCad. - person Trenton McKinney   schedule 01.09.2020