We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

getMaterialByName not working.

Home Forums General Questions getMaterialByName not working.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #33567
    GLiFTeK
    Customer

    Hi,
    I’ve got a var of an object by getObjectByName.
    ie: app.scene.getObjectByName(meshName);
    works great.

    now to get the material in it, “metal”..
    i have tobe all fancy and do this trick?…
    var material = v3d.SceneUtils.getMaterialByName(v3d.apps[0], 'materialName');

    but it does not work and says that material is undefined.

    where in the documents can i find info about this and why’s it not working?

    thanks!

    #33601

    I just tried that and it worked for me. May be there is a type in material name? :unsure:

    Attachments:
    You must be logged in to view attached files.

    Chief 3D Verger | LinkedIn | Twitter

    #33650
    GLiFTeK
    Customer

    I’m trying to do it where WHATEVER the material from the object is named.. it can still dynamically get it from the object.. whatever object.

    here is what i have..
    (the cubes’s material name is “metal”.)
    l

    and here is my console readout…

    material: visual_logic.js:477:13
    metal visual_logic.js:478:13
    mesh before script: visual_logic.js:480:13
    Cube visual_logic.js:481:13
    meshName:  Cube visual_logic.js line 507 > Function:4:9
    mesh after script: visual_logic.js:513:13
    Object { uuid: "7E17F35D-5682-401F-9A60-BF011A861DB7", name: "Cube", type: "Mesh", parent: {…}, children: [], up: {…}, position: {…}, rotation: {…}, quaternion: {…}, scale: {…}, … }
    visual_logic.js:514:13
    material before script: visual_logic.js:516:13
    metal visual_logic.js:517:13
    materialName:  metal visual_logic.js line 519 > Function:4:9
    material after script: visual_logic.js:526:13
    null

    this is being done because in the clipping planes script, you have to change a lot about the materials, and i like keeping materials that i’ve made in blender that have a lot of unique nodes etc. (this example is simple metal)

    is this problem happening because i’m asking it about a variable value which is just a text name? how can i extract the material (whatever material) should i skip the get material puzzle and combine that’s code with the script code?

    thanks!

    Attachments:
    You must be logged in to view attached files.
    #33662

    In the second exec script puzzle it should be:

    
    var material = v3d.SceneUtils.getMaterialByName(v3d.apps[0], materialName);
    

    instead of:

    
    var material = v3d.SceneUtils.getMaterialByName(v3d.apps[0], 'materialName');
    

    Co-founder and lead developer at Soft8Soft.

    #33706
    GLiFTeK
    Customer
Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.