Scripting: Searching for a command to turn on/off available model sets

Hi,
I am having another question related to scripting:
I would like to turn on/off any listed model sets. The problem is I could not find any command doing that.

The only similar was to delete it, but as I need it later in the script again, that was not a good way.

import os, re, sys
import os.path

root = lux.getSceneTree()

#show all model sets and child groups and parts
root.show()

#Define the list of Model Sets you want to render
model_sets = lux.getModelSets()
print(model_sets)

#hide all model sets
for modelset in model_sets:
print(modelset)
for node in root.find(name = modelset):
node.delete()

Can anybody give me a hint?

Thanks

setModelSets(…)
Um, did you use this?
I don’t know if the code is correct.

lux.setModelSets(name=‘another_model_set’)
Or
lux.setModelSets(‘another_model_set’)

If you know any other way, please leave a reply.
I’m curious.

1 Like

The function lux.getModelSets() gets the active Model Sets in the scene. When only a single Model Set (or a few) is active at a time, it won’t be able to get the inactive ones.

For manipulating Model Sets, you can get them as SceneNodes instead. This will allow you to get all Model Sets (including inactive ones), rename them, activate a selection etc.

Here is a simple example to get you started:

#get the contents of the scene as a SceneNode
root = lux.getSceneTree()

#find the Model Set nodes by filtering on the Model Set node type
msets = root.find(types = lux.NODE_TYPE_MODEL_SET)

#to activate Model Sets, a list needs to be passed to lux.setModelSets()
#create a new empty list
msetlist = []

#get the names of all Model Sets and append them to ‘msetlist’
for node in msets:
  msetname = node.getName()
  msetlist.append(msetname)

#use the list to activate a selection of Model Sets
#example 1: activate all Model Sets
lux.setModelSets(msetlist)
#example 2: simultaneously activate the 1st and 3rd Model Set
lux.setModelSets([msetlist[0], msetlist[2]])

Dries

3 Likes