Dear Monks,
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:
Sub genSplineMy()
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
+s1
End Sub
My perl script that is trying to do this:
use strict;
use Win32::OLE qw(in with);
use Win32::OLE::Variant;
use Win32::OLE::Const 'Microsoft Visio';
$Win32::OLE::Warn = 3;
my $Visio = Win32::OLE->new('Visio.Application', 'Quit');
$Visio->{Visible}=1 ;
my $doc = $Visio->Documents->Open("c:\\work\\tools\\perl\\visio\\basic
+_template.vst");
$doc->SaveAs('c:\\work\\tools\\perl\\visio\\test.vdx');
my @controlpoints = (1.5,10.25,1.84606,10.3302,2.21642,10.1541,2.375,9
+.875);
my @knots = (0,0,0,0,2.66958);
my $variant_controlpoints = Win32::OLE::Variant->new(VT_R8|VT_ARRAY|VT
+_BYREF, @controlpoints);
my $variant_knots = Win32::OLE::Variant->new(VT_R8|VT_ARRAY|VT_BYREF,
+@knots);
$Visio->Application->ActiveWindow->Page->DrawNURBS(3, 0, $variant_cont
+rolpoints, $variant_knots);
$doc->SaveAs('c:\\work\\tools\\perl\\visio\\test.vdx');
$doc->Close;
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:
http://msdn.microsoft.com/en-us/library/office/aa224588(v=office.11).aspx
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,
+ 7.5);
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:
- 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
Outside of code tags, you may need to use entities for some characters:
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.