Mark:

Thanks for getting back to me.  I'm afraid it still doesn't work.  With the method definition set to
    def count(self, entityTYPE=defaultNamedNotOptArg, nSelected=pythoncom.Empty):
        return self._ApplyTypes_(20002, 1, (3, 0), ((3, 1), (16387, 2)), 'count', None,entityTYPE
            , nSelected)


I still get
Traceback (most recent call last):
  File "[snip]\playFemap4me.py", line 80, in <module>
    nSelected = zSelect.count(eFemTyps.FT_ELEM)
  File "<COMObject feSelector>", line 2, in count
pywintypes.com_error: (-2147352561, 'Parameter not optional.', None, None)


I'll mention that I ran makepy.py with the command line argument "-o PyFemap.py".  In my code, I just import PyFemap, rather than importing gencache and running gencache.EnsureModule(etc.).  I've tried it both ways and it doesn't seem to make much difference.  Is something perhaps not getting imported properly by PyFemap?  Here's the top of that file, in case it helps:

# -*- coding: mbcs -*-
# Created by makepy.py version 0.4.95
# By python version 2.5.2 (r252:60911, Mar 27 2008, 17:57:18) [MSC v.1310 32 bit (Intel)]
# From type library 'femap.tlb'
# On Fri Sep 26 16:28:32 2008

"""Femap v9.31 Type Library"""
makepy_version = '0.4.95'
python_version = 0x20502f0

import win32com.client.CLSIDToClass, pythoncom
import win32com.client.util
from pywintypes import IID
from win32com.client import Dispatch

# The following 3 lines may need tweaking for the particular server
# Candidates are pythoncom.Missing, .Empty and .ArgNotFound

defaultNamedOptArg=pythoncom.Empty
defaultNamedNotOptArg=pythoncom.Empty
defaultUnnamedArg=pythoncom.Empty



Thanks again for your help.

- Greg Antal

Gregory W. Antal
Senior Technical Advisor
ATA Engineering, Inc.
11995 El Camino Real, Suite 200	
San Diego, CA  92130
www.ata-e.com

[EMAIL PROTECTED]
858-480-2072  (Phone)
858-792-8932  (Fax)


Mark Hammond wrote:

Try passing pythoncom.Empty for the out param - that will provide a VT_EMPTY param to the object, which it will hopefully accept and fill with the result.

 

Mark

 

From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] On Behalf Of Greg Antal
Sent: Tuesday, 7 October 2008 4:10 AM
To: python-win32@python.org
Subject: Re: [python-win32] ByRef params not working with PythonCOM

 

Greetings all.

I posted this a week ago and had no response, so I'll try again.  Any information would be helpful, even if it's just "that all looks right, no idea why it doesn't work."  I'll gladly provide more info if needed, or try a different statement of the problem if it isn't clear.

Thanks,
Greg Antal

---------------------

Greg Antal wrote:

Gentlemen:

I need to work with a TLB for a finite element pre/post processor called Femap.  Its API was built for Visual Basic, and it uses output arguments in many of its functions/methods.  Methods with only input arguments and return values work great, but I can't get anywhere with those that have output arguments.

Here's the documentation for a method 'Count' of the class 'feSelector':
Count ( entityType, nSelected )
Description:
  This method returns the number of entities of a given type that are currently selected
Input:
    INT4 entityType
        The entity type to query (node, element, etc)
Output:
    INT4 nSelected
        The number of "entityType" entities that are currently selected.
Return Code:  None


Here's the code makepy.py generated for this method:
    def count(self, entityTYPE=defaultNamedNotOptArg, nSelected=pythoncom.Missing):
        return self._ApplyTypes_(20002, 1, (3, 0), ((3, 1), (16387, 2)), 'count', None,entityTYPE
            , nSelected)


>From all the documentation I've been able to find (including the archives of this mailing list back to September 2005), my Python call should look like this:
nSel = zSelect.count(eFemTyps.FT_NODE)

When I try that, I get:
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
  File "<COMObject feSelector>", line 2, in count
com_error: (-2147352561, 'Parameter not optional.', None, None)


I've tried supplying the extra parameter, but that results in a 'type mismatch' error, which probably doesn't surprise anyone.  Can someone help?

Thanks,
Greg Antal

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

Reply via email to