Importing multiple objects

Started by Palinky, October 06, 2021, 09:20:14 AM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Palinky

Hi all!

I am relatively new to Keyshot and have run into a bit of an issue...
I am trying to figure out a way to import multiple objects, all in one go, into a Keyshot scene.

I have searched the forums here, and found an old thread with a batch rendering example project, but the import script doesn't work for me.
I changed the file type in the script, but i run into syntax errors that I have no idea how to fix. Needless to say, I am no code writer...

I have resorted to doing a batch import into Maya, then will try send the assets via the plugin to keyshot, but I was wondering if there is any way to batch import files into Keyshot 10.2

Here is the python script I tried to use:


# -*- coding: utf-8 -*-
# AUTHOR Dries Vervoort (Luxion)
# VERSION 0.0.1
# Batch render Toy Train models to images.
import os

def getGeometryImportOptions():
  importOptions = lux.getImportOptions()
  importOptions['center_geometry'] = False
  importOptions['snap_to_ground'] = True
  importOptions['up_vector'] = 2
  importOptions['adjust_camera_look_at'] = False
  importOptions['adjust_environment'] = False
  importOptions['update_mode'] = False
  importOptions['group_by_shader'] = False
  importOptions['group_by'] = 2
  importOptions['new_import'] = False
  importOptions['tessellation_quality'] = 0.15
  importOptions['accurate_tessellation'] = True
  return importOptions

def main():
  values = [("ifold", lux.DIALOG_FOLDER, "Folder to import STEP models from:", None)]
  opts = lux.getInputDialog(title = "Batch Render Model Collection",
                            desc = "Renders a collection of models in a folder to images.",
                            values = values,
                            id = "batchrenderSTEPmodels.py.luxion")
  if not opts: return

  importExtension = "step"
 
  importExtension = "STEP"
 
  importExtension = "sat"
 
  importExtension = "SAT"

  importFolder = opts["ifold"]

  importOptions = getGeometryImportOptions()

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

      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?")

main()


and here is the error I get:


File "console", line 1
    import os
            ^
SyntaxError: multiple statements found while compiling a single statement
0ms

any help would be much appreciated!

Erik Williams

Hello Palinky,

You may need to install Python for other Python Standard libraries to use the import os command.
It is supported but for security reasons it is not included in our Python library.

Let me know if that solves the issue for you.

Best Regards,

Erik Williams
Luxion Customer Support

Palinky

Hi Erik,

Thanks for the response! I downloaded python, but... I'm not sure what you mean by 'Python for other Python Standard libraries'
I am not very technically minded at all, and when I googled it, I couldn't really make heads or tails of the results.

do you have a link you could share where I could download the libraries you are talking about?

Thanks!

Erik Williams

Hello Palinky,

Depending on what version of Python you downloaded, it may be missing some standard libraries, or a standard string of commands and features, such as import os.
We recommend downloading at least Python 3.8.
This can be downloaded directly from https://www.python.org/downloads/.

Best Regards,

Erik Williams
Luxion Customer Support