Bonjour à tous,
Mon objectif est de commander une application (Softimage XSI v6.5) depuis un script python. Malheureusement, j'ai des erreurs incoherentes. J'espère que quelqu'un pourra m'aiguiller dans le monde du dispatch.
voici le code :
le testA() et le testC() me donnent la même erreur :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 def testA() : print "Test A starting..." from win32com.client import dynamic as d App = d.Dispatch( 'XSI.Application' ).Application print App.Version() def testB() : print "Test B starting..." import win32com App = win32com.client.dynamic.Dispatch( 'XSI.Application' ).Application print App.Version() def testC() : print "Test C starting..." import win32com.client import win32com.client.dynamic from win32com.client import gencache Gencache.EnsureModule('{269C4D8C-E32D-11D3-811D-00A0C9AC19A9}', 0, 1, 0) App = win32com.client.dynamic.Dispatch( 'XSI.Application' ).Application print App.Version()
Et le testB() me renvoie cette erreur :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 Test A starting... Traceback (most recent call last): File "test_pyxsi.py", line 29, in <module> testA() File "test_pyxsi.py", line 10, in testA App = d.Dispatch( 'XSI.Application' ).Application File "C:\Python25\Lib\site-packages\win32com\client\dynamic.py", line 105, in Dispatch IDispatch, userName = _GetGoodDispatchAndUserName(IDispatch,userName,clsctx) File "C:\Python25\Lib\site-packages\win32com\client\dynamic.py", line 98, in _GetGoodDispatchAndUserName return (_GetGoodDispatch(IDispatch, clsctx), userName) File "C:\Python25\Lib\site-packages\win32com\client\dynamic.py", line 78, in _GetGoodDispatch IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx, pythoncom.IID_IDispatch) pywintypes.com_error: (-2147024770, 'Le module sp\xe9cifi\xe9 est introuvable.', None, None)
Je suis desespéré !
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 Test B starting... Traceback (most recent call last): File "test_pyxsi.py", line 29, in <module> testB() File "test_pyxsi.py", line 16, in testB Application = win32com.client.dynamic.Dispatch( 'XSI.Application' ).Application AttributeError: 'module' object has no attribute 'client'
Merci d'avance pour vos réponses !
Manu.
PS : J'ai tenté d'effacer le repertoire gen_py, et de forcer la creation ensuite avec makepy mais cela ne change rien à mes problèmes. MakePy me presente neanmoins la Softimage|XSI Object Model Library...
Partager