Hide menu
Loading...
Searching...
No Matches
Thumbnail Generation Example

Table of Contents

Demonstrates how to generate and save an image of a model.

Overview

In this example we create a View_ImageWriter object which allows us to generate and save an image of ModelData_Model .

Implementation

The main function will have the following structure:

aModel = mtk.ModelData_Model()
# Reading the file
if not mtk.ModelData_ModelReader().Read(mtk.UTF16String(theSource), aModel):
print("Failed to read the file " + theSource)
return 1
  • Create an View_ImageWriter and set some parameters:
aWriter = view.View_ImageWriter()
aWriterParameters = view.View_ImageWriterParameters()
# Set writer parameters
aWriterParameters.SetImageWidth(1200)
aWriterParameters.SetImageHeight(720)
aWriterParameters.SetViewIsFitAll(True)
aBackgroundColor = view.View_ColorBackgroundStyle(view.View_Color(255, 255, 255))
aWriterParameters.SetViewBackground(aBackgroundColor)
aWriter.SetParameters(aWriterParameters)
  • Generate an image of a model and save it into a file:
# Generate the model image and save it into the file
if not aWriter.WriteFile(aModel, mtk.UTF16String(theDest)):
print("Failed to write the image file " + theDest)
return 1

Files