Author Topic: Script for linking materials with keywords?  (Read 3159 times)

0 Members and 1 Guest are viewing this topic.

Offline willchocks7

  • Newbie
  • *
  • Posts: 21
Script for linking materials with keywords?
« on: July 12, 2016, 10:02:38 pm »
Hi Everyone,

Is it possible to run a script that will automatically link together some materials?

For example:

Lets say I have two materials (in reality I have hundreds):

Metal frame1 [navy coat]
Metal frame 2 [navy coat]

They are identical materials but their names are different when I import them from my CAD program, and therefore I have to link them before I go about changing any material properties.

I was wondering if there was a way to quickly link them using the common keywords in their name (the keyword being [navy coat]

Is it possible?

And can anyone show me a script that would do undertake this task?

Thanks very much.

Offline Will Gibbons

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2807
  • Training Specialist at Luxion
    • KeyShot Training
Re: Script for linking materials with keywords?
« Reply #1 on: July 13, 2016, 06:17:00 am »
Scripting is not required to achieve what you want.

First off, when you import your model, KeyShot should link same materials/colors upon import by default unless you're on a much older version.

That said, in your Real-time view, right-click on a part with the material you wish to link, and click 'Select Parts With Material', then right-click on one of the highlighted parts in the scene tree (while all of the parts with that material are highlighted) and select Material>Link Material.

That should do it.

Another way to do this is to look at the in-scene materials tab in the project panel, select all materials you wish to link and right-click and select link materials. See attached images for this below.

Offline willchocks7

  • Newbie
  • *
  • Posts: 21
Re: Script for linking materials with keywords?
« Reply #2 on: July 13, 2016, 06:20:05 pm »
Thanks for your reply Will,

Unfortunately Keyshot is treating my seemingly 'identical' materials as 'non-identical' materials. When I click 'select all parts with this material' It only selects two or three parts.

I am using the latest pro version of Keyshot.

Attached is a photo of my materials.

If you take a look you will see that the materials aren't actually the same material applied to multiple parts. (if that makes sense)

My CAD program (Solid Edge) assigns a new material for each part it exports, even if the materials have the exact same values, they are still counted as separate and hence can't be linked through clicking 'select all parts with this material'.

Bit of a frustrating situation as I have many many materials to link and going through by hand and linking them can take quite a long time.

Offline Chad Holton

  • Hero Member
  • *****
  • Posts: 1370
    • Portfolio
Re: Script for linking materials with keywords?
« Reply #3 on: July 14, 2016, 05:38:45 am »
Hello,

You may be able to use material templates. Here's an older video but it's basically the same process:

Another thought, if material templates don't work the way you need it to, is to use the scene tree to search for the parts and once the parts are highlighted, you can then paste on a linked material. For example, you could search for "Metal frame" or just "Metal" or "Frame" (without quotes) and everything that has that part of the name will be highlighted and can then be linked by material.

Hope this helps.

Chad


Offline Will Gibbons

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2807
  • Training Specialist at Luxion
    • KeyShot Training
Re: Script for linking materials with keywords?
« Reply #4 on: July 14, 2016, 06:47:04 am »
I'll echo what Chad said and then add that using the search/filter function should help you out. Find the common thread. Looks like your CAD package uses a common keyword for each color ex. 'kiwi' search that, multi-select those, right-click and link.

Offline willchocks7

  • Newbie
  • *
  • Posts: 21
Re: Script for linking materials with keywords?
« Reply #5 on: July 18, 2016, 04:39:35 pm »
Material Templates was exactly what I needed. Had no idea it existed!

Thank you very much!

I can now assign all the correct materials with one click and link them easily with very little effort.

fantastic!

Offline Chad Holton

  • Hero Member
  • *****
  • Posts: 1370
    • Portfolio
Re: Script for linking materials with keywords?
« Reply #6 on: July 19, 2016, 07:12:18 am »
Awesome! Glad it worked out.  :)