How to load a texture file into the base color shader of a node (Iray) (SOLVED)

3djoji3djoji Posts: 1,092

I have one geometry which is splited into a great number of textured elements. Instead of loading one by one the textures of these elements, I write a little script which can do it automatically, based on a text description. I'm able to choose and retreive the node and/up to the material to work with but when I search the property of the material using the material.findProperty("Base Color"), it doesn't give any property.value and I'm not able to use the property.set value or Mat instruction.

 

Is there a simple way to load a texture file name into the "Base color" or any other property of that Iray shader?

Post edited by 3djoji on

Comments

  • Check that the name is right - click the gear on the slider, Parameter Settings, and copy the name from there.

  • 3djoji3djoji Posts: 1,092
    edited January 2018

    Thank you, it helps because the name, in that case is different than the label

    When I search the Property by name, should I include the path? For instance should I write

     property = material.findProperty("Diffuse Color");        or       property = material.findProperty("Base/Diffuse/Reflection/Diffuse Color");

     

    In both case, I get an error of my next script line : property.setMat(mat_name); // mat_name is the absolute path of the texture file

    Post edited by 3djoji on
  • MikeDMikeD Posts: 299

    Use the:

    property = material.findProperty("Diffuse Color"); property.setMap("absolute path.jpg");

    if you wanna load a single map that is NOT a layered image(.jpg, .png etc). Or:

    Scene.setPrimarySelection(objectNode);var oContentMgr = App.getContentMgr();oContentMgr.openFile("absolute path/file.duf", true);

    if you wanna load a material preset (file.duf file)

    This may help you!

  • 3djoji3djoji Posts: 1,092

    oki, thank you so much, I learn a lot and never find out what's going on until... I read MikeD post once again and.. so sorry, I'm stupid, I forget to concatenate the file extension... lol, it is always like that. But I read  and change some part of my code, it was really a great lesson.

Sign In or Register to comment.