Is it possible to export an image via script?

Nikolayan

New member
Hello!
I'm currently trying to make a rather complex script-plugin that would allow the user to extrude PNG images with 1 button click. The theoretical steps should be:

1. Locate the container's image texture and export it to the local disk. < SOLVED 1
2. Execute a local script on the exported image with system.StartApplication() that does the following steps:
>>> Extracts only the alpha channel of the image and saves it as a new black-and-white image
>>> Traces the new image using Inkscape's autotrace / brightness cutoff to convert it to a vector path
>>> Save the vector as a plain SVG, then convert it to Adobe Illustrator version 5 format (I actually found a program that can do this - it's called UniConvertor 1.1.5)
3. Back in Viz, create a new "Polygon" geometry plugin for the container and import the new .AI file as its path. <PROBLEM 2
4. Add an extrude plugin and set it up.
5. Hope the texture matches perfectly ontop of the new geometry, or else do some math to align them.

Here's what I'm having trouble with:

PROBLEM 1:
Exporting an image to local disk: I don't know if that is possible. I found a class called "ImportTask" in the viz engine documentation, but nothing about exporting.

PROBLEM 2: The Polygon plugin doesn't seem to be able to import .AI files automatically through script. If I had its source code and could see which functions it runs to perform that import that would help. Otherwise my only option would be to use the "POLYGONSTORAGE" field, which for the life of me I can't figure out how it works - if anyone has any ideas about it let me know.

If you have any insights into any of the 3 problems, let me know. Any help at all is appreciated! :)
 
Last edited:
Sorry, I got lazy but here are a few scripted plugins from the treasurechest. You might find some usefull commands from there to get you started. TextureTools
Thank you, the "Edit_external" script had what I needed - the viz engine command for exporting.
Unfortunately, I'm hitting a brick wall with the Polygon plugin - it just doesn't behave like a normal geometry plugin. Can't create it or access its properties at all via code. Any ideas?

The below example script fails to do anything. I wonder if it's a bug in how that particular plugin is made...

Code:
sub OnInitParameters()
    RegisterPushButton("TEST", "TEST", 0)
end sub

sub OnExecAction(buttonId As Integer)
    this.CreateGeometry("BUILT_IN*Geom*Polygon")
    println(this.GetGeometryPluginInstance().GetParameterDouble("PRECISION"))
    this.GetGeometryPluginInstance().PushButton("Import")
  
    this.Update()
    this.Scene.UpdateSceneTree()
end sub
 
Last edited:
try
this.CreateGeometry("BUILT_IN*GEOM*POLYGON")
Hey, thanks, I had forgotten that viz engine paths and commands are case-sensitive.
That's one problem less. If you have an idea on how to perform the import too, I'd be very thankful.
 
Back
Top