Images without background

Hello,

We often export images of the simulation models. However, we need the images without a background. Removing the floor/grid is a first step, but is it possible to create an image of the models and have the rest of the image as a transparent background? Or is this something that would be possible in the future?

Hy,

I do this with an workaround:

  1. Set the background-color in VC to one color which is almost unique compared to colors on components.

  2. Save the picture

  3. gimp: how to make a transparent background | Thomas Cokelaer's blog

Hope that helps?

Regards
Feature

Another approach is to export the model as 3MF or OBJ

Then open the 3MF or OBJ in Paint 3D and save as PNG with transparency

The appearance of the model won’t be exactly the same as in VC, but for many cases it’s good enough.

Thanks for the recommendations!
At the moment, we are using the suggestion of captain_feature, but were looking for a method that would be more efficient. With a lot of images, it can be a time consuming task. We’ll stick to this method for now and see if a functionality like that might be introduced in a later version of Visual Components :slight_smile: :crossed_fingers:.

The Blender addon has this feature, here’s a video of it in action (in the last minute or so of the video):

1 Like

Use vcApplication.saveBitmap() command to auto export the image for every X seconds or manually click.

The Blender addon seems like a good solution, thanks!

With the vcApplication.saveBitmap() command I don’t know how to make sure that the background is invisible. I just get the exact image that is on the screen, including the background.

Oh, OK, I see, my bad.
Need to handle transparency after saveBitmap().

I found that it is not hard to handle image transparency.
Since can use PIL in VC.

from PIL import Image

png = Image.open("D:\\sample.png")
png = png.convert("RGBA")

data = png.getdata()
newData = []

# Choose white pixel here
for item in data:
  if item[0] == 255 and item[1] == 255 and item[2] == 255:
    newData.append((255, 255, 255, 0))
  else:
    newData.append(item)

png.putdata(newData)
png.save("D:\\sample_exported.png", "PNG")

FYI. Here is the add-on from scratch.

https://forum.visualcomponents.com/t/transparent-background-and-merge-new-background/2666

1 Like

@chungmin Thanks! This also seems like a clean and easy to use solution!