[python-win32] Array and CATIA

2007-05-07 Thread Andreas Holtz
Hello,

we have a problem to pass an array to the GetComponents()-Method of 
CATIA-COM-Object.

The method expects an array as method-parameter. The result will be written in 
the given array. The array must be initialized with 12 elements. You can't pass 
an empty array/dictionary to the method.

For unknown reason, this does not work. The array is not changed.

Does anybody has a solution for this?

Not working source:

#  snip 
CATIA = win32com.client.dynamic.Dispatch("CATIA.Application")
selection = CATIA.ActiveDocument.selection

# error checking
if selection.Count == 0:
  CATIA.Statusbar = "exit1"
  return
if selection.Item2(1).Type <> "Product":
  CATIA.Statusbar = "exit2"
  return

rootProduct = selection.Item2(1).Value
positionArray = [0.0,1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0,11.0]
result = rootProduct.Products.Item(1).Position.GetComponents(positionArray)
print result
# print result gives defaultvalues of positionArray, 
# but should give other values
#  snip 

Thanks in advance

Andreas
-- 
"Feel free" - 10 GB Mailbox, 100 FreeSMS/Monat ...
Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail
___
Python-win32 mailing list
Python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32


[python-win32] Fw: Python COM and Photoshop

2007-05-07 Thread Sam The Cat
I thought I'd try this again -- still no progress on my debugging.  From 
using Visual Basic it seems that the interface is expecting an array of type 
varint where each element of the array is another array.  The inner arrays 
are two elements long (an x and y data point)

I have also tried using the array module but I still get the same errors --  
basically anything that I try in Python results in a error indicating that 
only a 1-dimensional arrays are supported -- which seems weird since the 
vbasic code is not making a single dimensional array.

Any thoughts are appreciated



> Help !
>
> I am writing some COM code in Python to control photoshop.  Several
> functions of PS require an "Array" argument.  In the  examples of VBscript
> or javascript the Array type is used.  I have tried what would appear to 
> be
> the equivalent in Python -- Lists and Tuples -- but to no avail. Anyone 
> have
> any insight  on what via the COM interface is equivalent to an Array in
> javascript ?
>
> Here is the Javascript example code
>
> .
> selRegion  = Array(Array(1,1),Array(1,2),Array(2,2),Array(2,1))
> Doc.Selection.Select(selRegion,1,0,0)
> .
>
> Here is my interpretation in Python
>
> ...
> selregion = [(1,1),(1,2),(2,2),(2,1)]
> print selregion
> doc.Selection.Select(selregion,1,0,0)
> ..
>
> Here is the error code generated
>
> ..
> F:\automation>test2.py
> [(1, 1), (1, 2), (2, 2), (2, 1)]
> Traceback (most recent call last):
>   File "F:\automation\test2.py", line 19, in ?
> doc.Selection.Select(selregion,1,0,0)
>   File ">", line 3, in Select
> pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'Adobe
> Photoshop', 'Illegal argument - argument 1\n- Only arrays
> with dimension 1
> are supported', None, 0, -2147220262), None)
>
>
> 
>
> I have tried many differnet permutations of structure for the selregion
> variable.  Any scalar or single dimension array returns an "Illegal
> Argument" response with no further details -- any thing that resembles a 
> two
> dimensional array returns the result above.
>
> Any help / thoughts would be appreciated
>
> 


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


Re: [python-win32] Python COM and Photoshop

2007-05-07 Thread Sam The Cat
One more thought -- I have tried both Early and Late binding COM calls and I 
get the same error message either way.



>I thought I'd try this again -- still no progress on my debugging.  From 
>using Visual Basic it seems that the interface is expecting an array of 
>type varint where each element of the array is another array.  The inner 
>arrays are two elements long (an x and y data point)
>
> I have also tried using the array module but I still get the same 
> errors --  basically anything that I try in Python results in a error 
> indicating that only a 1-dimensional arrays are supported -- which seems 
> weird since the vbasic code is not making a single dimensional array.
>
> Any thoughts are appreciated
>
>
>
>> Help !
>>
>> I am writing some COM code in Python to control photoshop.  Several
>> functions of PS require an "Array" argument.  In the  examples of 
>> VBscript
>> or javascript the Array type is used.  I have tried what would appear to 
>> be
>> the equivalent in Python -- Lists and Tuples -- but to no avail. Anyone 
>> have
>> any insight  on what via the COM interface is equivalent to an Array in
>> javascript ?
>>
>> Here is the Javascript example code
>>
>> .
>> selRegion  = Array(Array(1,1),Array(1,2),Array(2,2),Array(2,1))
>> Doc.Selection.Select(selRegion,1,0,0)
>> .
>>
>> Here is my interpretation in Python
>>
>> ...
>> selregion = [(1,1),(1,2),(2,2),(2,1)]
>> print selregion
>> doc.Selection.Select(selregion,1,0,0)
>> ..
>>
>> Here is the error code generated
>>
>> ..
>> F:\automation>test2.py
>> [(1, 1), (1, 2), (2, 2), (2, 1)]
>> Traceback (most recent call last):
>>   File "F:\automation\test2.py", line 19, in ?
>> doc.Selection.Select(selregion,1,0,0)
>>   File ">", line 3, in Select
>> pywintypes.com_error: (-2147352567, 'Exception occurred.', (0, 'Adobe
>> Photoshop', 'Illegal argument - argument 1\n- Only arrays
>> with dimension 1
>> are supported', None, 0, -2147220262), None)
>>
>>
>> 
>>
>> I have tried many differnet permutations of structure for the selregion
>> variable.  Any scalar or single dimension array returns an "Illegal
>> Argument" response with no further details -- any thing that resembles a 
>> two
>> dimensional array returns the result above.
>>
>> Any help / thoughts would be appreciated
>>
>>
> 


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


Re: [python-win32] Fw: Python COM and Photoshop

2007-05-07 Thread Mark Hammond
> > F:\automation>test2.py
> > [(1, 1), (1, 2), (2, 2), (2, 1)]
> > Traceback (most recent call last):
> >   File "F:\automation\test2.py", line 19, in ?
> > doc.Selection.Select(selregion,1,0,0)
> >   File ">", line 3, in Select
> > pywintypes.com_error: (-2147352567, 'Exception occurred.',
> (0, 'Adobe
> > Photoshop', 'Illegal argument - argument 1\n- Only arrays
> > with dimension 1
> > are supported', None, 0, -2147220262), None)

>From the line:

> >   File ">", line 3, in Select

It appears you are not using 'makepy' for the object (maybe as makepy is not
support for that object).  If possible, you should try and use a makepy
based object.  The easiest way is something like:

from win32com.client.gencache import EnsureDispatch
select = EnsureDispatch(select) # try and convert into makepy based object.

If you can get that to work, you might have more luck, as python can
determine the exact type of the variant from the type-library.

Good luck,

Mark

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