[RESOLVED] Beyond the "Render images" examples script

Started by Marc, July 15, 2019, 11:35:23 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Marc

Hi,
I see that there is the "Render images" script in the script examples, which allows me to load a material template on different models. Is it possible with one of those script exmaples to load multiple material templates on one model? That would be the solution to my main problem I have right now.

Any tip or hint is welcome and very appreciated!

Kind regards
Marc

INNEO_MWo

Hello Marc.


Will Gibbons wrote a great blog entry with a cool breakdown for the scripting console. https://blog.keyshot.com/keyshot-scripting-tutorial-automate-your-rendering
This scripts use multiple material templates. Maybe you'll find the right script parts for your needs?!


Hope that helps
Cheers
Marco

Marc

Hi Marco,

Thank you. Yes I took a look at that script. This seems perfect but I don't know how to "convert" it to my project. Just started with Python and this seems (in the moment) too big for me. I'm doing some tests right now with the newest trial version to decide if I'm able to control keyshot the way I need it for a future project. It definitely has the power but I'm unsure if I have the brains to steer it.

Niko Planke

Hello Marc,

The function lux.setMaterialTemplate() should do the trick.
Just call it multiple times with different templates and it will apply multiple material templates.

If you feel adventurous or want more control, you can use a combination of  the lux.getSceneTree(), .find() and .setMaterial() to directly apply you materials.

Did you check the scripting documentation at: https://www.keyshot.com/scripting/doc/8.2/ already? if not i would highly suggest you check what is currently possible and bookmark it.

Marc

Hello Niko,

thank you very much! These are the kind of urgently needed tips to get me going. I will try to embedd the .lux function into the "Render Images" script.

Best regards
Marc

Marc

For everyone interested in this issue. This is a very interesting discussion with an attached script similar to my problem:

Topic: Script for Multiple ColorWays help - Render Layers
https://www.keyshot.com/forum/index.php?topic=22086.msg94100;topicseen#msg94100

I'm trying to change this script for my purpose now.

Marc

#6
For anyone interested in this "batchrender-multiple-scenes-multiple-cameras-multiple-material-templates" issue. Here is the script I'm working with (see attachment).
You can define the material templates and if there are no naming convention problems (naming of parts / materials - see tutorial on how to setup material templates!) the script runs really great rendering out all the cameras in the scenes and loading the different materail templates which have been setup. But it seems like the author (he changed "toy train batch rendering script" from Luxion) took the lux.openfile() module out so the "open all scenes from folder" feature isn't working. I'm trying to get it to work now with parts of the original "toy train batch rendering script" from Dries Vervoort but had no luck so far. When I got an error because something wasn't defined I defined the missing attributes but something is still going wrong.

From (undefined):
      lux.openFile()

To:
for file in os.listdir(importFolder):
    if file.endswith(importExtension):
      modelList.append(file)
      print(modelList)

      scenePath = sceneInfo.get('file')
      lux.openFile(scenePath)

      if lightingPreset != 'Currently used':
        lux.setLightingPreset(lightingPreset)

      importPath = importFolder + os.path.sep + file

      print("Importing {}".format(importPath))
      if not lux.importFile(path = importPath, opts = importOptions):
        raise Exception("Error in import! User cancelled?")


Gives me following error:

    Traceback (most recent call last):
  File "<string>", line 233, in <module>
  File "<string>", line 191, in main
Exception: Path cannot be empty!

I don't get it, because the Path (scenePath) is assigned!

When I run the script on an already open file I get this error:

Exception:

Traceback (most recent call last):
  File "<string>", line 240, in <module>
  File "<string>", line 205, in main
Exception: Must specify a dictionary!


Has someone an idea on how to setup the openfile module properly inside of the attached script? I don't want to import scenes, I want to open onece scene after the other and let the script do his job (assigning material templetes).

Pheeeeew, it's hard to learn Python while working on an actual project!

Cheers
Marc