General tips before you start scripting your customized utilities in Python for your SimLab Composer:

  • Always, remember to add from simlabpy import * at the beginning of your script.
  • In python, the semicolon ; is not required at the end of statements.
  • For a single line comment, use # at the beginnig of the line. For multiple lines, use """ at the beginning of the first line and another """ at the end of the last line.
  • You can do Python scripts with:
    1. The Scripts Library of the Automation workbench in SimLab Composer (write, edit, and run in GUI-mode only).
    2. SimLab Visual Scripting (write and run in GUI and non-GUI modes using -fl command).
    3. CLI (run only in non-GUI mode using -py command).

  • Note: Read more about Approaches to automatically do things with SimLab Composer on SimLab blog website.

Scene

The Scene class.

Scene()
Example
from simlabpy import *
scene = Scene() # Always returns a reference to Scene singleton instance.
Instance Members
reset()
remove(sceneNode)
importFile(filePath)
setSavingModeToSaveAs(saveAsBool)
openFile(filePath)
exportFile(filePath)
exportFile(filePath, sceneStates)
render(imagePath, width, height, skipOpenFolder)
renderAnimation(outputDir, beginFrame, endFrame)
getRenderSettings()
packTheScene(outputFilePath, baseFileFormat)
movieMaker(outputFolderPath, inputImagesFolderPath, videoQuality, frameRate, outputFormat, audioFilePath)
bakeTexture(smart)
bakeTexture(nodes, smart)
bakeTextureForAnimation(nodes, smart)
setTextureBakingSettings(minSize, maxSize, spp, qualityLevelTop, optimizeBakingTime, maxPolygonsPerObject)
createDoorAndCabinetsAnimation(inputFilePath)
getNodeByName()
getNodeBySubString()
getNodesBySubString()
getSceneStateByName()
getMaterialByName()
captureSceneState()
captureSceneStateFromSelection()
setPDFTemplateFileName(pdfTemplateFilePath)
captureSceneImage(outputImagePath, outputImageWidth, outputImageHeight)
createMaterial()
createCamera()
createLight()
createInstanceOf(sceneNode)
createRoundTableCameraAnimation(rotateClockWise)
exportSceneData(txtfilePath)
isolate(sceneNode)
unisolate()
snapToGround(nodeName)
retainMaterialPalette(materialPaletteFilePath, retainType)
exportVrPackage(outputFile, packageTitle, packagePublisher, packageDescription, packageType, packageImage, optimize)
addAttribute(sceneNodeName, attributeName, attributeValue, attributeCategory)
replaceObject(includes, doesNotInclude, inputFilePath)
isGUIMode()
getSelectedNode()
applyReplaceRules(filePath)
mergeIdenticalMaterials()
mergeNodesOnMaterial(sceneNodes)
decimateMeshes(sceneNodes, decimationPercentage)
smoothNormals(sceneNodes)
optimizeTextures(compressMaps, removeDuplicatedMaps, maxMapWidth, maxMapHeight, maxEnvironmentWidth, maxEnvironmentHeight, outputDirectory)
replaceMaterial(sceneNode, newMaterial)

Camera

The Camera class.

Camera()

Extends Node

Example
from simlabpy import *
newCamera = Camera()
Instance Members
getFov()
getPosition()
getTargetPosition()
getUp()
setFov(fieldOfView)
setPosition(newPosition)
setTargetPosition(newTargetPosition)
setUp(newUpVector)

BoundingBox

The BoundingBox class.

BoundingBox(sceneNode: Node)
Parameters
sceneNode (Node) A scene node to calculate its bounding box.
Example
from simlabpy import *
scene = Scene()
sceneNode = scene.getSelectedNode()
nodeBoundingBox = BoundingBox(sceneNode)
Instance Members
getCenter()
getMax()
getMin()

SceneState

The SceneState class.

SceneState()
Instance Members
apply()
isMaterialIncluded()
isCameraIncluded()
isVisibilityIncluded()
isLightIncluded()
isEnvironmentIncluded()
isTransformIncluded()
setMaterialIncluded(includeMaterialState)
setCameraIncluded(includeCameraState)
setVisibilityIncluded(includeVisibilityState)
setLightIncluded(includeLightState)
setEnvironmentIncluded(includeEnvironmentState)
setTransformIncluded(includeTransformState)

RunTime

The RunTime class.

RunTime()
Example
from simlabpy import *
runtime = RunTime()
Instance Members
setView(newCamera)
setView(topView)
fitAll(drawingAreaWidth, drawingAreaHeight, zoomOutFactor)

Properties
STANDARD_VIEW_TOP (str) : The standard top view.
STANDARD_VIEW_BOTTOM (str) : The standard bottom view.
STANDARD_VIEW_FRONT (str) : The standard fron view.
STANDARD_VIEW_BACK (str) : The standard back view.
STANDARD_VIEW_RIGHT (str) : The standard right view.
STANDARD_VIEW_LEFT (str) : The standard left view.
STANDARD_VIEW_DEFAULT (str) : The standard default view.
args (Arguments) : To access arguments which run against SimLab Composer from CLI.
dictionaty (Dictionary) : To access dictionary of SimLab Composer.
ui (UI) : Provides UI dialogs and messages.
Example
from simlabpy import *
runtime = RunTime()
topView = runtime.STANDARD_VIEW_TOP
runtime.setView(topView)
from simlabpy import *
runtime = RunTime()
bottomView = runtime.STANDARD_VIEW_BOTTOM
runtime.setView(bottomView)
from simlabpy import *
runtime = RunTime()
frontView = runtime.STANDARD_VIEW_FRONT
runtime.setView(frontView)
from simlabpy import *
runtime = RunTime()
topView = runtime.STANDARD_VIEW_TOP
backView = runtime.STANDARD_VIEW_BACK
runtime.setView(backView)
from simlabpy import *
runtime = RunTime()
rightView = runtime.STANDARD_VIEW_RIGHT
runtime.setView(rightView)
from simlabpy import *
runtime = RunTime()
leftView = runtime.STANDARD_VIEW_LEFT
runtime.setView(leftView)
from simlabpy import *
runtime = RunTime()
defaultView = runtime.STANDARD_VIEW_DEFAULT
runtime.setView(defaultView)
from simlabpy import *
runtime = RunTime()
arguments = runtime.args
from simlabpy import *
runtime = RunTime()
currentDictionary = runtime.dictionary
from simlabpy import *
runtime = RunTime()
theUi = runtime.ui

UI

The ui object; a public property of RunTime class.

UI()
Example
from simlabpy import *
runtime = RunTime()
theUi = runtime.ui
Instance Members
getBool(message, label, init)
getString(message, label, init)
getValue(fromInt, message, label, init)
getColor(title, init)
getNode(message, label)
getNodeArray(message, label)
getOpenFileName(title, init, filter)
getSaveFileName(title, init, filter)

Arguments

The arguments object. A public property of RunTime class.

Arguments()
Instance Members
isFound(key)
getAsNumber(key)
getAsString(key)
getAsColor(key)
getAsVector3(key)
getAsNumberArray(key)
getAsStringArray(key)
getAsColorArray(key)
getAsVector3Array(key)

Dictionary

The dictionary object. A public property of RunTime class.

Dictionary()
Instance Members
isFound(key)
getAsNumber(key)
getAsString(key)
getAsColor(key)
getAsVector3(key)
getAsNumberArray(key)
getAsStringArray(key)
getAsColorArray(key)
getAsVector3Array(key)
set(key, floatValue)
set(key, stringValue)
set(key, colorValue)
set(key, vectorValue)
set(key, floatValues)
set(key, stringValues)
set(key, colorValues)
set(key, vectorValues)

Light

The Light class.

Light()

Extends Node

Example
from simlabpy import *
light  = Light()
Instance Members
getBrightness()
getInnerConeAngle()
getOuterConeAngle()
getColor()
getType()
getIESFileName()
setBrightness(newBrightness)
setInnerConeAngle(newInnerConeAngle)
setOuterConeAngle(newOuterConeAngle)
setColor(newColor)
setType(lightType)
setIESFileName(iesFilePath)

Color

The Color class.

Color(r: float, g: float, b: float)
Parameters
r (float) The red channel.
g (float) The green channel.
b (float) The blue channel.
Example
from simlabpy import *
r = 0.1
g = 0.2
b = 0.3
newColor = Color(r, g, b)
Instance Members
red()
green()
blue()
setRed(newR)
setGreen(newG)
setBlue(newB)

Material

Material class.

Material()
Example
from simlabpy import *
material = Material()
Instance Members
getName()
getDiffuseColor()
getAmbientColor()
getEmissiveColor()
getSpecularColor()
getEta()
getDiffuseTexture()
getBumpTexture()
getOpacityTexture()
getReflectionTexture()
getNormalTexture()
getRoughnessTexture()
getMaterialType()
setName(newMaterialName)
setDiffuseColor(newdiffuseColor)
setAmbientColor(newAmbientColor)
setEmissiveColor(newEmissiveColor)
setSpecularColor(newSpecularColor)
setEta(newEtaValue)
setDiffuseTexture(newDiffuseTexture)
setBumpTexture(newBumpTexture)
setOpacityTexture(newOpacityTexture)
setReflectionTexture(newOpacityTexture)
setNormalTexture(newOpacityTexture)
setRoughnessTexture(newRoughnessTexture)
setMaterialType(newMaterial)
set(newMaterial)

Matrix4x4

The Matrix4x4 class.

Matrix4x4(): Matrix4x4
Returns
Matrix4x4: The data type of the returned variable.
Example
from simlabpy import *
matrix = Matrix4x4()
Instance Members
set()
getInverse()
scale(scaleX, scaleY, scaleZ)
scaleInPlace(scaleX, scaleY, scaleZ)
multiply(multiplyMatrix)
multiplyInPlace(multiplyMatrix)
transformPosition(inputVector)
translate(null-null)
translateInPlace(inputVector)
rotate(inputFromVector, inputToVector)
rotateInPlace(inputVector1, inputVector2)
rotateAboutVectorInPlace(angle, aroundVector)

Node

The Node class.

Node()
Example
from simlabpy import *
sceneNode = Node()
Instance Members
getName()
setName(newName)
getVisibility()
setVisibility(newVisibility)
getTransform()
setTransform(transform)
getParent()
setParent(newParent)
computeBoundingBox()

RenderSettings

The RenderSettings class. A private property of Scene class.

RenderSettings()
Example
from simlabpy import *
scene = Scene()
renderSettings = scene.getRenderSettings()

Properties
turbidity (int)
renderSolarDisc (bool)
enableAmbientLight (bool)
showStatistics (bool)
enableGroundShadow (bool)
groundReflectionEnableFresnel (bool)
groundReflectsEnvironment (bool)
enableHemisphericalBackplate (bool)
renderMode (int)
backgroundType (int)
backgroundColor (int)
skyStrength (int)
previewRatio (int)
spp (int)
sphericalBackplateRadius (int)
ambientLightStrength (int)
specularDepth (int)
lightDepth (int)
groundReflectionStrength (int)
groundShadowStrength (int)
backplateType (int)
solarHorizontalAngle (float)
solarElevation (float)
groundReflectionRoughness (float)
sunStrength (float)
brightness (float)
envPath (str)
sphericalBackPlateImage (str)
Example
from simlabpy import *
scene = Scene()
renderSettings = scene.getRenderSettings()
renderSettings.turbidity = 1
runtime = RunTime()
runtime.ui.alert(str(renderSettings.turbidity))
from simlabpy import *
scene = Scene()
renderSettings = scene.getRenderSettings()
renderSettings.renderSolarDisc = False
runtime = RunTime()
runtime.ui.alert(str(renderSettings.renderSolarDisc))
from simlabpy import *
scene = Scene()
renderSettings = scene.getRenderSettings()
renderSettings.enableAmbientLight = False
runtime = RunTime()
runtime.ui.alert(str(renderSettings.enableAmbientLight))
from simlabpy import *
scene = Scene()
renderSettings = scene.getRenderSettings()
renderSettings.showStatistics = False
runtime = RunTime()
runtime.ui.alert(str(renderSettings.showStatistics))
from simlabpy import *
scene = Scene()
renderSettings = scene.getRenderSettings()
renderSettings.enableGroundShadow = False
runtime = RunTime()
runtime.ui.alert(str(renderSettings.enableGroundShadow))
from simlabpy import *
scene = Scene()
renderSettings = scene.getRenderSettings()
renderSettings.groundReflectionEnableFresnel = False
runtime = RunTime()
runtime.ui.alert(str(renderSettings.groundReflectionEnableFresnel))
from simlabpy import *
scene = Scene()
renderSettings = scene.getRenderSettings()
renderSettings.groundReflectsEnvironment = False
runtime = RunTime()
runtime.ui.alert(str(renderSettings.groundReflectsEnvironment))
from simlabpy import *
scene = Scene()
renderSettings = scene.getRenderSettings()
renderSettings.enableHemisphericalBackplate = False
runtime = RunTime()
runtime.ui.alert(str(renderSettings.enableHemisphericalBackplate))
from simlabpy import *
scene = Scene()
renderSettings = scene.getRenderSettings()
renderSettings.renderMode = 1
runtime = RunTime()
runtime.ui.alert(str(renderSettings.renderMode))
from simlabpy import *
scene = Scene()
renderSettings = scene.getRenderSettings()
renderSettings.backgroundType = 1 # 0 enables HDR only, 1 enables Sun only, 3 enables both.
runtime = RunTime()
runtime.ui.alert(str(renderSettings.backgroundType))
from simlabpy import *
scene = Scene()
renderSettings = scene.getRenderSettings()
newColor = Color(1, 0, 0)
renderSettings.backgroundColor = newColor
runtime = RunTime()
runtime.ui.alert(str(renderSettings.backgroundColor.red()))
from simlabpy import *
scene = Scene()
renderSettings = scene.getRenderSettings()
renderSettings.skyStrength = 1
runtime = RunTime()
runtime.ui.alert(str(renderSettings.skyStrength))
from simlabpy import *
scene = Scene()
renderSettings = scene.getRenderSettings()
renderSettings.previewRatio = 1
runtime = RunTime()
runtime.ui.alert(str(renderSettings.previewRatio))
from simlabpy import *
scene = Scene()
renderSettings = scene.getRenderSettings()
renderSettings.spp = 100
runtime = RunTime()
runtime.ui.alert(str(renderSettings.spp))
from simlabpy import *
scene = Scene()
renderSettings = scene.getRenderSettings()
renderSettings.sphericalBackplateRadius = 1
runtime = RunTime()
runtime.ui.alert(str(renderSettings.sphericalBackplateRadius))
from simlabpy import *
scene = Scene()
renderSettings = scene.getRenderSettings()
renderSettings.ambientLightStrength = 1
runtime = RunTime()
runtime.ui.alert(str(renderSettings.ambientLightStrength))
from simlabpy import *
scene = Scene()
renderSettings = scene.getRenderSettings()
renderSettings.specularDepth = 1
runtime = RunTime()
runtime.ui.alert(str(renderSettings.specularDepth))
from simlabpy import *
scene = Scene()
renderSettings = scene.getRenderSettings()
renderSettings.lightDepth = 1
runtime = RunTime()
runtime.ui.alert(str(renderSettings.lightDepth))
from simlabpy import *
scene = Scene()
renderSettings = scene.getRenderSettings()
renderSettings.groundReflectionStrength = 1
runtime = RunTime()
runtime.ui.alert(str(renderSettings.groundReflectionStrength))
from simlabpy import *
scene = Scene()
renderSettings = scene.getRenderSettings()
renderSettings.groundShadowStrength = 1
runtime = RunTime()
runtime.ui.alert(str(renderSettings.groundShadowStrength))
from simlabpy import *
scene = Scene()
renderSettings = scene.getRenderSettings()
renderSettings.backplateType = 1 # 0 for Image, 1 for Spherical, 2 for From Environment, and 3 for Single Color.
runtime = RunTime()
runtime.ui.alert(str(renderSettings.backplateType))
from simlabpy import *
scene = Scene()
renderSettings = scene.getRenderSettings()
renderSettings.solarHorizontalAngle = 1.1
runtime = RunTime()
runtime.ui.alert(str(renderSettings.solarHorizontalAngle))
from simlabpy import *
scene = Scene()
renderSettings = scene.getRenderSettings()
renderSettings.solarElevation = 1.1
runtime = RunTime()
runtime.ui.alert(str(renderSettings.solarElevation))
from simlabpy import *
scene = Scene()
renderSettings = scene.getRenderSettings()
renderSettings.groundReflectionRoughness = 1.1
runtime = RunTime()
runtime.ui.alert(str(renderSettings.groundReflectionRoughness))
from simlabpy import *
scene = Scene()
renderSettings = scene.getRenderSettings()
renderSettings.sunStrength = 1.1
runtime = RunTime()
runtime.ui.alert(str(renderSettings.sunStrength))
from simlabpy import *
scene = Scene()
renderSettings = scene.getRenderSettings()
renderSettings.brightness = 1.1
runtime = RunTime()
runtime.ui.alert(str(renderSettings.brightness))
from simlabpy import *
scene = Scene()
renderSettings = scene.getRenderSettings()
renderSettings.envPath = "C:\\Users\\SimLab\\AppData\\Roaming\\SimLab\\SimLab Composer 10\\data\\hdrs\\5516F55C-FE6C-41EB-8465-A19A1C9E482E.exr"
runtime = RunTime()
runtime.ui.alert(renderSettings.envPath)
from simlabpy import *
scene = Scene()
renderSettings = scene.getRenderSettings()
renderSettings.sphericalBackPlateImage = "C:\\Users\\SimLab\\AppData\\Roaming\\SimLab\\SimLab Composer 10\\data\\plates\\856EB27A-96A6-426D-9151-162CC4AA67BD.jpg"
runtime = RunTime()
runtime.ui.alert(renderSettings.sphericalBackPlateImage)

Texture

The Texture class.

Texture()
Example
from simlabpy import *
newTexture = Texture()
Instance Members
getScaleU()
getScaleV()
getOffsetU()
getOffsetV()
getPath()
setScaleU(newScaleU)
setScaleV(newScaleV)
setOffsetU(newOffsetU)
setOffsetV(newOffsetV)
setPath(textureMapPath)

Image

Image class.

Image(sceneState: SceneState)
Parameters
sceneState (SceneState) The scene state to have a reference to its preview image.
Example
from simlabpy import *
scene = Scene()
sceneState = scene.getSceneStateByName("Scene1")
image = Image(sceneState)
Instance Members
getPath()
setPath(imageFilePath)

Vector3

The Vector3 class.

Vector3()
Example
from simlabpy import *
vector = Vector3()
Instance Members
getX()
getY()
getZ()
getLength()
setX(newX)
setY(newY)
setZ(newZ)
normalize()
subtract(vector)
scaleInPlace(scale)
scale(scale)
dot(vector)
cross(vector)

SimLab Python API for SimLab Composer.

Author: SimLab Soft <support@simlab-soft.com>
Copyright: SimLab Soft 2020.