I'm trying to create a spline object in Visio using win32::OLE in perl. I'm struggling with converting the equivalent macro into perl code, especially the part where I have to pass an array of control points and knots for Visio to generate the spline.
The equivalent macro is:
Dim ControlPoints1(5) As Double
Dim Knots1(3) As Double
ControlPoints1(0) = 1.5
ControlPoints1(1) = 10.25
ControlPoints1(2) = 2.21642
ControlPoints1(3) = 10.1541
ControlPoints1(4) = 2.375
ControlPoints1(5) = 9.875
Knots1(0) = 0
Knots1(1) = 0
Knots1(2) = 0
Knots1(3) = 2.66958
Application.ActiveWindow.Page.DrawNURBS 3, 0, ControlPoints1, Knot
My perl script that is trying to do this:
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Visio';
$Win32::OLE::Warn = 3;
my $Visio = Win32::OLE->new('Visio.Application', 'Quit');
my $doc = $Visio->Documents->Open("c:\\work\\tools\\perl\\visio\\basic
my @controlpoints = (1.5,10.25,1.84606,10.3302,2.21642,10.1541,2.375,9
my @knots = (0,0,0,0,2.66958);
my $variant_controlpoints = Win32::OLE::Variant->new(VT_R8|VT_ARRAY|VT
my $variant_knots = Win32::OLE::Variant->new(VT_R8|VT_ARRAY|VT_BYREF,
$Visio->Application->ActiveWindow->Page->DrawNURBS(3, 0, $variant_cont
I get this error when i run the perl script:
OLE exception from "test.vdx - Microsoft Visio":
An exception occurred.
Win32::OLE(0.1709) error 0x86db0898
in METHOD/PROPERTYGET "DrawNURBS" at visio_test.pl line 19
I used the variant type as recommended in the DrawNURBS documentation here:
I've tried a bunch of different ways to create that variant and pass it into the DrawNURBS method, but I'm struggling to get it to work.
I can draw a line just fine in Visio using this command
$Visio->Application->ActiveWindow->Page->DrawLine(3.1875, 8.75, 4.875,
It's just the spline and the array argument that's evading me.
Would appreciate any perl wisdom I could be offered here.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] |