Jim Ragsdale wrote:
> I am trying to access the femap API, and having a bit of trouble. Here
> is a simple example:
>
> from win32com.client import Dispatch
> femap = Dispatch("femap.model")
> rc = femap.feAppGetActiveView(viewID)
>
> This method, according to the documentation, is supposed to return a
> long integer in viewID. If I do not define viewID, python returns the
> error:
>
> NameError: name 'viewID' is not defined

Right, because it's not.  Python never passes variables by reference. 
The language simply does not have that concept.  When  a COM method has
an output parameter, Pythoncom turns it into a true output parameter. 
What you probably need is this:

    viewID = femap.feAppGetActiveView()


> I ran makepy and it generates a file, but I don't know if it is using
> it or not. 

The use of makepy is critical when the interface includes reference
parameters.


> In the file, I can find the definition for the method:
>
> def feAppGetActiveView(self, nViewID=pythoncom.Missing):
>     return self._ApplyTypes_(20376, 1, (3, 0), ((16387, 2),),
> u'feAppGetActiveView', None,nViewID)
>
> To me it looks like win32 is not getting the information about the
> variable types from com.

Sure it is.  The type code 16387 is VT_I4 + VT_BYREF, which means a
4-byte integer passed by reference.

-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.

_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to