MoI discussion forum
MoI discussion forum

Full Version: PNG Export with transparent background

From: noskule
16 Dec 2017   [#1]
Hi All
I would like to export a png with transparent background and cant figure out how to define the transparent background, thats what I have so far:

script: /* Custom screenshot */ var prev_background = moi.view.viewportBackgroundColor; moi.view.viewportBackgroundColor = 0xFFFFFF; moi.view.lineWidth = 3; moi.grid.display = false; moi.grid.showXYAxes = false; moi.view.showAxisIcon = false; moi.view.meshAngle = 3; var v = moi.ui.getActiveViewport(); if ( v != null ) { moi.view.lineWidth = 4; var img = v.render( 3840, 2160 ); moi.view.lineWidth = 1; var name = img.getSaveFileName(); if ( name != '' ) img.save( name ); }moi.view.lineWidth = 1; moi.grid.display = true; moi.grid.showXYAxes = true; moi.view.showAxisIcon = true; moi.view.meshAngle = 8; moi.view.viewportBackgroundColor = prev_background;

Has anyone an idea how to define "viewportBackgroundColor" or how can I do it?

Thanks Ben
From: Michael Gibson
16 Dec 2017   [#2] In reply to [#1]
Hi Ben, there isn't any way for that particular rendering method to generate a transparent background.

But there is another way you could get one - if you do an export to .ai format, and check the option for generating a shaded background image, there will be a companion PNG file generated along with the .ai file and that PNG file will have a transparent background.

Also if you export to PDF format, the PDF will contain in it the same kind of bitmap which you could probably extract with copy/paste.

- Michael