win32, COM, and Solidworks (again) - Still Trying
Markus Wankus
markus_wankus at hotmail.com
Thu Aug 7 08:54:33 EDT 2003
On Thu, 07 Aug 2003 21:08:21 +1000, Mark Hammond
<mhammond at skippinet.com.au> wrote:
> Markus Wankus wrote:
>
>> Hmmm...'Not Implemented'. Because this fails, I can't obtain the CLSID
>> of itself, thus it can't use the makepy generated code to bind itself
>> properly. I always get back dumb CDispatch objects. I have been trying
>> to hack a way of getting the CLSID of the dispatch object, but it just
>> isn't there.
>>
>> Anyway - if anyone reading this knows anything about what I am talking
>> about, your help would be greatly appreciated.
>
> You should use code similar to:
>
> mod = gencache.EnsureModule("...", ...)
>
> ob = Dispatch("Whatever.Object")
> # ob now "dumb dispatch", but should be object "foo"
> # in the gencache module
> # Explicitly convert ob to one of these object.
> ob = mod.Foo(ob)
>
> Mark.
>
>
Thanks, Mark. That's what I have been doing in the past (on your advice),
but I have been trying to automate that process and found it next to
impossible (from what I can figure out anyway). The reason this is an
incredible pain is that every single method or attribute of 'ob' that
returns an object, returns a dumb object. I need to know what class it is
*supposed* to be, and run it through the gencache module class constructor.
This is a huge pain.
I realize this is nothing to do with win32all - it is Solidworks. Is there
a way I can tell them about this problem and possibly get them to fix it?
What have they not done in their C++ code that is making their
implementation of COM so stupid?
If there was a away I could make my own Dispatch class that forced this re-
instantiation I would be happy, but I can't see any way to figure out what
gencache class I need for a given object at runtime. I wonder if I could
somehow generate my own, smarter module from scratch using the gencache
module as a starting point. It would be incredibly painful...
Anyway - thanks again for your help, Mr. Hammond. Perhaps I should let
this drop already and accept the fact that it can't easily be done...
--
Mark
More information about the Python-list
mailing list