KeyShot Forum

Technical discussions => Extending KeyShot => Scripting => Topic started by: sethcshort on May 23, 2017, 04:33:20 PM

Title: A Batch Import script, and a question
Post by: sethcshort on May 23, 2017, 04:33:20 PM
I made a script that allows you to batch import any kind of file from a specified folder (merely choose what extension to import, or * for all).

I've also put options similar to what you'd see in the standard Import dialog.

However, I'm a bit confused as to how to replicate the "Group by Object" / "Group by Material" option in the standard dialog. There seem to be two import options that could be related to this:

group_by_shader  -- True/False
and/or
group_by --  integer? -- currently set to "2", not sure what this means

What should these options be set to for Group by Object or Group by Material? Or is there another option I should be looking at?

Right now the script uses "group_by_shader" (represented as "Group by Material" for clarity). Is this correct usage?

Thanks,
Seth
Title: Re: A Batch Import script, and a question
Post by: DriesV on May 25, 2017, 06:48:44 AM
Hi Seth,

group_by can have 3 integer values.
* GroupByLayer = 0
* GroupByShader = 1
* GroupByObject = 2

GroupByLayer is mostly useful for Alias files.

I hope that helps.

Dries
Title: Re: A Batch Import script, and a question
Post by: sethcshort on May 25, 2017, 10:58:16 AM
It definitely helps!

What's the relationship between group_by_shader and group_by? Do I need group_by_shader to be True as well as group_by = 1 in order to group by shader?

FYI Here's an updated script that allows the user to group imported objects into any pre-existing root-level group in the scene. (Through what I think is a pretty clever use of python's "set union" and "set intersection" functions in order to determine what objects in the scene are new after import.) I'd prefer to be able to allow the user to create a new group on the fly, but I don't see any way to do that in script. Is there?