how to make Array variable type as vbscript Array in order to transfer to a Adobe Illustrator Application?

1 Ansicht (letzte 30 Tage)
I want to draw a triangle in adobe illustrator via COM server:
aAI = actxserver('Illustrator.application');
aAI.Documents.Add;
aGrp = aAI.ActiveDocument.GroupItems.Add;
aPath = aGrp.PathItems.Add;
% error appeared here when transfer the coordinate of vertices of a triangle by many ways:
aPath.SetEntirePath([100,100,100,304,23,334])
aPath.SetEntirePath({100,100;100,304;23,334;})
aPath.SetEntirePath({100,100,100,304,23,334;})
aPath.SetEntirePath({100;100;100;304;23;334;})
aPath.SetEntirePath({[100,100;100,304;23,334;]})
aPath.SetEntirePath([100,100;100,304;23,334;])
aPath.SetEntirePath([100,100;100,304;23,334;]')
Error using Interface.Adobe_Illustrator_CC_Type_Library.PathItem/SetEntirePath
Invoke Error, Dispatch Exception:
Source: Adobe Illustrator
Description: Illegal argument - argument 1
- Only arrays with dimension 1 are supported
The working vbs code is :
aPath.SetEntirePath Array( Array(100,100), Array(123,1224), Array(456,66) )
A similar issue has been solved in python, but not matlab.
I think the problem may be COM Types .
But I cannot find a way to solve it.
Unsupported Types ---MATLAB does not support the following COM types.
---Structure
---Sparse array
---_ Multidimensional SAFEARRAYs (greater than two dimensions)_ ( But this array is a 2-dimension array, not more than two. )
---Write-only properties
See Also
https://uk.mathworks.com/matlabcentral/answers/92424-how-can-i-pass-arguments-to-an-activex-server-from-matlab-7-0-r14-as-one-dimensional-arrays
https://uk.mathworks.com/matlabcentral/answers/94888-how-can-i-pass-arguments-by-reference-to-an-activex-server-from-matlab-7-0-r14
https://uk.mathworks.com/help/matlab/matlab_external/handling-com-data-in-matlab-software.html#bq553lb

Antworten (1)

Guillaume
Guillaume am 31 Okt. 2018
Bearbeitet: Guillaume am 31 Okt. 2018
It looks like SetEntirePath expects a 1D array of 1D arrays. In theory that would be a cell array of vectors in matlab, so:
aPath.SetEntirePath({[100, 100], [100, 304], [23, 334]})
Is that function documented somewhere (accesible publicly) to know for sure what it expects?
edit: As per your first answer link, you may need to first issue:
feature('COM_SafeArraySingleDim', 1);
to force matlab to pass the arrays as 1D.
  2 Kommentare
raym
raym am 31 Okt. 2018
The input argument is array of [x,y] coordinate pairs as from adobe scripting guide. I tried the code you suggested, but the error is the same:
Invoke Error, Dispatch Exception:
Source: Adobe Illustrator
Description: Illegal argument - argument 1
- Only arrays with dimension 1 are supported
Guillaume
Guillaume am 31 Okt. 2018
Even after you've issued
feature('COM_SafeArraySingleDim', 1)
?
I'm asking for the documentation because array of [x,y] coordinate pairs is not a COM type. It's. Hopefully, the documentation would state exactly what COM type it expects (SAFEARRAY of SAFEARRAY of VARIANT ?)

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Operators and Elementary Operations finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by