Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

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

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, + 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.

In reply to Passing SAFEARRAY type to Visio win32::ole object from Perl by ketanh

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others studying the Monastery: (9)
    As of 2017-05-23 07:06 GMT
    Find Nodes?
      Voting Booth?