Questions on COM Objects scripting

Mark Hammond MarkH at ActiveState.com
Tue Sep 4 02:54:16 EDT 2001


Maan Hamze wrote:

>>>>from win32com.client import pythoncom
>>>>pythoncom.LoadTypeLib("d:\winpov\breeze\program\Breeze20.tlb")
>>>>
> Traceback (most recent call last):
>   File "<interactive input>", line 1, in ?
> com_error: (-2147312566, 'Error loading type library/DLL.', None, None)


Note that you have single backslashes, and the "\b" is being translated 
to ASCII 8.

> My mistake Mark.  It was a Typo.  This is what the Breeze doc mentions:
> "All  functions are available though the Breeze Designer **scene** object.
> This
> object is pre-created when using macros **from within Breeze Designer**.
> That is
> to use any on the following functions a scene. should be added to the front
> of the function."


OK - so "scene.whatever" should work.

> Actually Breeze Designer is a povray modeller, but it is not done by the
> povray people.  It translates a scene/model into povray syntax.
> From inside Breeze Designer I had the macro:
> $Python
> import win32traceutil
> from win32com.client import Dispatch
> print globals()   #to print into the Python Trace Collector of PythonWin
> scene=Dispatch("breeze.scene")    #notice small case letters :)
> rest of code......


For ActiveScripting applications, the "scene" object should magically 
appear.  There should be no need to create such an object manually. 
ActiveScripting itself defines how this magic happens.


> Please note that I used "breeze.scene" this time.  I was using
> "Breeze.Scene" before because that is what is in the Windows Registry (it is
> not listed in PythonWin COM browser so I looked in the registry, found it,


COM itself is not case sensitive.  So the string passed to Dispatch() 
generally does *not* care about case.

However, the documentation for the ActiveScripting support implies that 
a magic variable called "scene" should already be setup for you.  As 
with any other Python variable, the case does matter.

So if the documentation is correct, then "scene.whatever" should work 
without any need to use the Dispatch() function.


> 2.  That is what I am getting in the Python Trace Collector (by using print
> globals() in the macro):
>  {'ax': <win32com.axscript.client.pyscript.AXScriptAttribute instance at
> 02A815BC>, 'win32traceutil': <module 'win32traceutil' from
> 'd:\python\win32\lib\win32traceutil.pyc'>, 'Scene':
> <NamedItemAttribute<ScriptItem at 44574700: Scene>>, etc......etc.........
> 
> So, yep, it is....... Scene (not scene).  But it is breeze.scene that is
> working not Breeze.Scene.


OK - so "Scene.whatever" should work :)  Forget everything about 
"Breeze.Scene".  Assume that magically code similar to:

Scene = Dispatch("Breeze.Scene")

has already been executed, and just start using the "Scene" variable.

Mark.




More information about the Python-list mailing list