try using the full namespace. it sounds like the module isn't loading
everything it needs.



import win32com.client



app = client.Dispatch("XSI.Application").Application

--
Jon Swindells
jon_swinde...@fastmail.fm





On Tue, Jan 14, 2014, at 07:20 PM, Tony Barbieri wrote:

This is in Softimage 2013 SP1 btw.



On Tue, Jan 14, 2014 at 12:17 PM, Tony Barbieri <[1]great...@gmail.com>
wrote:

Hello!

Sorry for such a newbish question but I'm having a hard time isolating
a problem in some code.  Sometimes this works, sometimes it doesn't and
I can't find out how to fix it.  Basically I have some code running in
a python module that is outside of a typical Softimage Plugin.  I've
tried to getting a handle to the Softimage Application object 2
different ways:

from win32com.client import Dispatch
Application = Dispatch("XSI.Application").Application

and

from win32com.client import dynamic
Application = dynamic.Dispatch("XSI.Application").Application

The error I am getting the first time I run my code is:

#     metadata_dict[ 'workgroups_loaded' ] = str( "; ".join(
Application.Workgroups ) )
#   File "C:\Program Files\Autodesk\Softimage 2013
SP1\Application\python\Lib\site-packages\win32com\client\dynamic.py",
line 495, in __getattr__
#     raise pythoncom.com_error, details
# 2028 - pywintypes.com_error: [2](-2147352567, 'Exception occurred.',
(0, None, u'Invalid argument specified.', None, 0, -[3]2147418113),
None)

The second time I run the code that line works fine and I get an error
at:

#     custom_params.append( customProp.AddParameter2("metadata",
c.siString, yaml_metadata) )
#   File "<COMObject <unknown>>", line 7, in AddParameter2
#   File "C:\Program Files\Autodesk\Softimage 2013
SP1\Application\python\Lib\site-packages\win32com\client\dynamic.py",
line 258, in _ApplyTypes_
#     result = self._oleobj_.InvokeTypes(*(dispid, LCID, wFlags,
retType, argTypes) + args)
# 2028 - pywintypes.com_error: [4](-2147352567, 'Exception occurred.',
(0, None, u'Invalid argument specified.', None, 0, -[5]2147418113),
None)

It's very odd and seems to be a problem with the way Dispatch is
working but I'm too much of a newb to say for sure...Are these just
false trails and not the actual errors that are occuring?  If I run
Application.Workgroups in the script editor before ever running this
code it will error out at the second error I posted above.  Am I
missing some sort of initialization procedure that has to happen before
I can run code in an outside python module?

Any help is much appreciated!

Best,

--
-tony




--
-tony

References

1. mailto:great...@gmail.com
2. tel:%28-2147352567
3. tel:2147418113
4. tel:%28-2147352567
5. tel:2147418113

Reply via email to