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

1 次查看(过去 30 天)
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

回答(1 个)

Guillaume
Guillaume 2018-10-31
编辑:Guillaume 2018-10-31
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 个评论
raym
raym 2018-10-31
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 2018-10-31
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 ?)

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Operators and Elementary Operations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by