Author Topic: A Batch Import script, and a question  (Read 2031 times)

0 Members and 1 Guest are viewing this topic.

Offline sethcshort

  • Jr. Member
  • **
  • Posts: 99
A Batch Import script, and a question
« 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

Offline DriesV

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2412
  • Product Specialist at Luxion
Re: A Batch Import script, and a question
« Reply #1 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

Offline sethcshort

  • Jr. Member
  • **
  • Posts: 99
Re: A Batch Import script, and a question
« Reply #2 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?
« Last Edit: May 25, 2017, 12:39:58 pm by sethcshort »