Quantcast
Viewing all articles
Browse latest Browse all 12845

VB.net scaling / Resize and export as SVG

Hi,

 

I'm using Illustrator CS4 and VB.NET 2008.

 

I'm doing a fairly simple operation in VB.net using Illustrator.  I load an  .AI file that was saved out of Illustrator and then resave it as a SVG file.  This works fine.

 

I need to scale up the SVG since for whatever reason the SVG artwork is smaller than the AI file.    This happens even if you just save the SVG file straight out of CS2/CS3/CS4/CS5 not using any automation.  Must be a feature, not a bug.

 

Anyway, I am able to set the scalematrix but for whatever reason, when I try to apply it, I can't get the syntax or object reference right.

 

I've looked at the illustrator CS4 Scripting reference(see below) and it says " artItem.Transform totalMatrix".  If I use that syntax  VB.net complains that the "Method arguments must be enclosed in parethesis"

 

If I enclose it,Like this: artitem.Transform(scalematrix)

 

I get this Warning     "Variable 'artitem' is used before it has been assigned a value. A null reference exception could result at runtime. "  and of course, at run time it barfs with a null exception.

 

Any suggestions?  I've dug through the illustrator objects trying to see if I've defined artitem wrong or something.  I'm stuck.

 

Thanks,

 

Mark


 

---------

 

      Dim illusapp As New Illustrator.Application
      Dim illusdoc As Illustrator.Document
      Dim scalematrix As Illustrator.Matrix
      Dim artitem As Illustrator.PathItem
      illusapp.UserInteractionLevel = Illustrator.AiUserInteractionLevel.aiDontDisplayAlerts
      
      Dim svgOpt = new illustrator.ExportOptionsSVG
      svgOpt.DTD = Illustrator.AiSVGDTDVersion.aiSVG1_0   

 

            illusdoc = illusapp.Open("c:\test\test.ai")

 

            scalematrix = illusapp.GetScaleMatrix(125,125)

'------ Problem starts here.

            artitem.transform(totalmatrix)
'------ Problem ends here.

 

            illusdoc.Export("c:\test\test.svg",Illustrator.AiExportType.aiSVG,svgopt)
            illusdoc.Close

 

-------

From Adobe Illustrator CS4 Scripting Reference.

     Applying transformations with a matrix
'Creates a new translation and rotation matrix then
'applies it to all items in the current document


Set appRef = CreateObject("Illustrator.Application")

 

'Move art half an inch to the right and 1.5 inch up on the page

 

     Set moveMatrix = appRef.GetTranslationMatrix(72 * 0.5, 72 * 1.5)

 

'Add a rotation to the translation -- 10 degrees counterclockwise

 

     Set totalMatrix = appRef.ConcatenateRotationMatrix(moveMatrix, 10)

 

'Apply the transformation to all art in the document

 

For Each artItem In appRef.ActiveDocument.PageItems
     artItem.Transform totalMatrix
Next


Viewing all articles
Browse latest Browse all 12845

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>