Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

win32com problem: more than one instance

205 views
Skip to first unread message

Thomas Rademacher

unread,
Aug 31, 2007, 8:20:22 AM8/31/07
to
Hello,

I start my script convert.py simultaneously in any dos-shells several
times. But I get every time the same solidworks instance.
I see in the proccess (task) manager only one solidworks.exe
Therefore I get for all simultaneous conversions the same output file.

I tested the same code with excel (test_excel.py) and her I get many
instances of excel in proccess (task) manager.
How can I get many instances of solidworks?

Is it a problem of python?
Or is it a problem of the Solidworks-COM-Implemention and I get the
same problem with an C++ client implementation?

Thanks for your help, Thomas

convert.py
import pythoncom
pythoncom.CoInitializeEx(pythoncom.COINIT_MULTITHREADED)

sldworks = gencache.EnsureModule('{83A33D31-27C5-11CE-
BFD4-00400513BB57}', 0x0, 13, 0)
sw = sldworks.ISldWorks(DispatchEx('SldWorks.Application'))
swmodel, errors, warnings = sw.OpenDoc6(sourceName,
constants.swDocPART, constants.swOpenDocOptions_Silent, "")
activeDoc = sw.ActiveDoc
retval, errors, warnings = swmodel.SaveAs4(targetName,
constants.swSaveAsCurrentVersion ,
constants.swOpenDocOptions_Silent )

pythoncom.CoUninitialize()

test_excel.py

import pythoncom
pythoncom.CoInitializeEx(pythoncom.COINIT_MULTITHREADED)

myExcel = win32com.client.DispatchEx('Excel.Application')
myExcel.Visible = 1
Excel = myExcel.Workbooks.Open(excelfile, 0, False, 2)
Excel.Saved = 1
Excel.Close()
myExcel.Quit()
del myExcel
del Excel

pythoncom.CoUninitialize()

Tim Golden

unread,
Aug 31, 2007, 8:36:20 AM8/31/07
to Thomas Rademacher, pytho...@python.org
Thomas Rademacher wrote:
> Hello,
>
> I start my script convert.py simultaneously in any dos-shells several
> times. But I get every time the same solidworks instance.
> I see in the proccess (task) manager only one solidworks.exe
> Therefore I get for all simultaneous conversions the same output file.

I *think* -- and I'm really hoping someone more knowledgeable
can chip in here -- that it's down to the particular COM
object implementation. ie Excel may choose to offer you
separate instances (or whatever they're called) while SolidWorks
may not.

TJG

Stefan Schukat

unread,
Aug 31, 2007, 12:05:37 PM8/31/07
to Thomas Rademacher, pytho...@python.org

Hello Thomas,

excel registers its COM objects with REGCLS_SINGLEUSE that means one COM
object is created
per process. In Solidworks it seems that that they register with
REGCLS_MULTIPLEUSE, which means
on process can serve more than one COM object. Hence you have no chance
to get multiple instances
running in any COM client.

Stefan

> --
> http://mail.python.org/mailman/listinfo/python-list
>

0 new messages