Hello Andreas, thanks for this workaround suggestion. Do you know if this will work if I want to evaluate something context sensitive? I.E. Instead of evaluating something in the global context like the previously mentioned *CATIA.ActiveProduct.Position.**GetComponents(components)* which would refer to the toplevel element, I want to use Python to navigate to some other *Product *and then pass that to the VBScript to call *someproduct.**Position.GetComponents(components). *Can I simply pass a Python COM Object to *CATIA.SystemService.Evaluate* as a parameter?
I will definitely try this on Monday. An other idea I came up over the weekend is using the VARIANT type, like it is described here <http://docs.activestate.com/activepython/3.4/pywin32/html/com/win32com/HTML/variant.html> do you think that is a viable option, or am I misunderstanding the purpose of this construct? best regards Peter Enenkel 2017-02-19 16:23 GMT+01:00 Andreas Holtz <a.ho...@gmx.net>: > Hi Peter, > > From Python call Catia.SystemService.Evaluate() and hand over a VB script > that does what you need > but returns an Array. > > This works for all CATIA methods that use an Array as > Input/Output-parameter. > > Regards > > Andreas > > > Peter Enenkel schrieb am 17.02.2017 um 23:29: > > Hello All, > > > > > > I'm trying to read some data from CATIA v5 (which is an older CAD > application) via its COM server. > > Overall it works rather well, even if I'm fairly new to COM > communication. > > > > Nevertheless I have run into a problem: One specific function > *GetComponents * is supposed to return > > its results via an array passed by reference. As far as I can tell it is > exactly the same problem as > > in (1)https://mail.python.org/pipermail/python-win32/2002- > November/000562.html > > <https://mail.python.org/pipermail/python-win32/2002- > November/000562.html> and > > (2)https://mail.python.org/pipermail/python-win32/2014-July/013234.html > > <https://mail.python.org/pipermail/python-win32/2014-July/013234.html> > unfortunately there doesn't > > appear to be a solution as of yet. > > > > The python call looks something like this > > a = list(range(0,12)) > > b = catapp.ActiveProduct.Position.GetComponents(a) > > print(a) # outputs (0,1,2,3,4,5,6,7,8,9,10,11) instead of the actual > values > > The equivalent VBScript code is > > Dim a(11) As Float > > CATIA.ActiveProduct.Position.GetComponents(a) > > MsgBox a(0) & ", " & a(1) & ... > > The VBScript works as intended, the python one just passes the array > back out unmodified. > > > > As both other threads state: The Position object above has two methods > *GetComponents *and > > *SetComponents *that each take a *CATSafeArrayVariant *as an argument. > This *CATSafeArrayVariant > > *should in this case be a one-dimensional array of real values. > CATSafeArrayVariant is a typedef for > > a *CATVariant *which itself is *typedef any CATVariant*. > > > > Any help would be appreciated. As stated above I haven't done much with > COM, but otherwise I'm > > reasonably computer savvy and know my way around python. Obviously Catia > is a commercial application > > but I have access to the .tlb file if that helps. > > > > > > best regards > > Peter Enenkel > > > > > > _______________________________________________ > > python-win32 mailing list > > python-win32@python.org > > https://mail.python.org/mailman/listinfo/python-win32 > > > _______________________________________________ > python-win32 mailing list > python-win32@python.org > https://mail.python.org/mailman/listinfo/python-win32 >
_______________________________________________ python-win32 mailing list python-win32@python.org https://mail.python.org/mailman/listinfo/python-win32