Script Import Options

Hi there!

Does anyone know if it’s possible to access these settings through scripting? I’ve gone through the documentation, but I couldn’t find the following options in the dictionary provided by lux.getImportOptions():

Environment ,Image style and Studio import on or off.

Any insights or suggestions would be greatly appreciated. Thank you!

image

Hi @fernando.andre.gomes,

I’m not really into scripting so I might be totally wrong but if I look at the manual at the bottom of getImportOptions(…) I think inclusion_options is the one you might need

inclusion_options = A bitwise collection of flags determining which features to import. Set to 31 for all features.

1 Like

Hey,

I can confirm what Oscar mentioned.
The "inclusion_options " is the key you need to add to the Import options dictionary
It looks like we need to update the documentation there.

So the bit values would be:
Nothing= 0
GEOMETRY = 1
CAMERAS = 2
ENVIRONMENTS = 4
IMAGE_STYLES = 8
STUDIOS = 16

So if you want to include geometry and cameras you would use 1+2=3
If you want to include geometry, cameras and imagestyles you would use 1+2+8=11

You should be able to just add the "inclusion_options " Key to the dictionary and use it as “opts” in lux.import File().

I will make sure the documentation gets updated to reflect this.

2 Likes

That is extremely helpful! I had read about those options in the documentation, but I couldn’t find these bitwise collection values. This will completely change the script I’ve been working on. I attempted a different approach since I couldn’t import only what I needed. Hahaha! Now my script will be much more functional. Thank you so much!

Also, speaking of the documentation, there are a couple of other things that I couldn’t find:

  1. We have a getLibraryEnvironments() function, but I couldn’t locate where I can set them from the library.
  2. renderFrames() or renderAnimation() don’t seem to have a start frame option. It appears that if there’s an animation, it always takes the first frame. It would be great to have the ability to manually set the start and end frames.

Thanks again for your assistance!
Hope to share soon some of my scripts with you all!

1 Like

Hey,

So getLibraryEnvironments() will give you an Environment object on which you can call setLightingEnvironment (…) to set the lighting environment.

Setting a frame range to render is indeed not possible at the moment.
As a workaround you can use setAnimationFrame(…) to manually set the frames and render a still image for each frame, and use encodeVideo(…) to then create the video file from the rendered frames.

I will of course forward this as as a feature request to the responsible.

1 Like

Hi Niko
Thanks again for the information, it helped me here.
But I think it works a little bit differently than what you suggested. We get a list of strings from getLibraryEnvironments(). Here is a print:

image

What seems to work is to use lux.getActiveEnvironment() this will bring an Environment object
that we can setLightingEnvironment() with what we have in getLibraryEnvironments().

I knew about the set LightingEnvironment(), but how is described in the documentation, seemed like it would paste the library environment as an image and I wanted it with all pins and details as saved. But I tested it here and it brings all pins.

Ah you got me there.
I mixed up getLibraryEnvironments() and getActiveEnvironment().

So just for me to be sure. Does everything work for you now, or are ther pending questions?

1 Like

Thanks for your assistance! I’ve successfully addressed all my concerns, and everything is functioning smoothly now. Your input made a significant difference. Many thanks!

I am happy I could help.

1 Like

Hello there,
I’ve come across a new question regarding the import options in KeyShot. I’ve been experimenting with different values in the lux.getImportOptions() dictionary while importing using my script. However, it appears that a particular option (shown in the image below) in the preference menu seems to override what I set in the importFile options.

When I run my script with the “open file” option enabled, it opens the file instead of importing it. Has anyone encountered a workaround for this issue within the script itself?