#!/usr/bin/env python # coding:utf-8 import os, win32com.client bname = "signal" path = os.path.join(os.getcwd(), bname + '.scl') print(path) s = win32com.client.Dispatch("Simatic.Simatic") print(s, type(s)) Pro = s.Projects("Test") print(Pro, type(Pro)) Prg = Pro.Programs("S7") print(Prg, type(Pro)) _Src = win32com.client.Dispatch("Simatic.S7Source") Src = Prg.Next("Sources").Next.Add(bname, _Src, path)
Вывод:
C:\Users\and\Desktop\signal.scl <COMObject Simatic.Simatic> <class 'win32com.client.CDispatch'> Test <class 'win32com.client.CDispatch'> S7 <class 'win32com.client.CDispatch'> Traceback (most recent call last): File "Test.py", line 20, in <module> Src = Prg.Next("Sources").Next.Add(bname, _Src, path) File "<COMObject <unknown>>", line 3, in Add File "C:\Users\and\AppData\Local\Programs\Python\Python35-32\lib\site-packages\win32com\client\dynamic.py", line 228, in __int__ return int(self.__call__()) File "C:\Users\and\AppData\Local\Programs\Python\Python35-32\lib\site-packages\win32com\client\dynamic.py", line 197, in __call__ return self._get_good_object_(self._oleobj_.Invoke(*allArgs),self._olerepr_.defaultDispatchName,None) pywintypes.com_error: (-2147352567, 'Ошибка.', (0, None, None, None, 0, -2147467259), None) Для продолжения нажмите любую клавишу . . .