Access To Material Texture Path

The Building Coder has offered us a clue to finding a Material’s images: http://bit.ly/mattextpath

What would one have to do to turn that into a Dynamo node?

image

3 Likes

https://github.com/erfajo/OrchidForDynamo/issues/34

I presume it will be implemented soon.
At the moment I have a solution with Python.

#Copyright Alberto Tono alberto.tono@hok.com

import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager

doc = DocumentManager.Instance.CurrentDBDocument

def toList(obj):
    if hasattr(obj, '__iter__'): return obj
    else: return [obj]
    
mats = toList(UnwrapElement(IN[0]))

for mat in mats:
	appearanceAssetId = mat.AppearanceAssetId
	assetElem = doc.GetElement(appearanceAssetId)
	getRenderingAsset = assetElem.GetRenderingAsset()
	genericDiffuseProperty = getRenderingAsset.FindByName("generic_diffuse")
	connectedAsset = genericDiffuseProperty.GetSingleConnectedAsset()
	bitmapProperty = connectedAsset["unifiedbitmap_Bitmap"]
	path = bitmapProperty.Value

OUT = path

5 Likes

Appreciate you sharing the code here as well @Alberto_Tono. Even more so considering it was deleted from the Github issues page… :roll_eyes:

2 Likes

Sad :frowning: Hope he will implement, at least.

1 Like

Looks useful. Please post the working DYN showing IN[0] .

1 Like


Be sure to place in a .dyf node and set the lacing. Thanks a lot True for the request.
The node took inspiration from several links and materials. https://thebuildingcoder.typepad.com/files/sd124625_visual_appearance_of_materials_api_boris_shafiro_handout.pdf

2 Likes

Hello, I’ve created the script as mentioned in @Alberto_Tono’s message. However, I’m being returned only nulls, even for the materials that I know have a texture image at a path.

What might be going wrong?

Hi Alberto, what should I set the lacing to?

Hello Randy, did you end up figuring this out?

Hi,

You can also use the Material Find Texture Path node.

1 Like

Thanks, that helps. Does it just ignore materials without texture paths?

Yes, if there is no texture, there is no result.
Maybe I should add a null instead.

Is there an easy way to filter out a material without a texture? I’d like to create a list with a column for material name and a column for texture path.

Hello Alban_de_Chasteigner

Did you in the end add the “null” to those materials, which don`t have any textures? Filtering out materials without textures would be also great using the node you mentioned.

Also another question: right now the node lists all textures without sorting between different types of textures (diffuse, cut-out, bump, etc.). Is there a way to achieve that that each category of maps could be listed by file path and when there is no texture attached, the node returns a null? (Diffuse, Cut-Out, Bump, etc.). It could be extremely useful for listing out Material Libraries to Excel. Unfortunately I cannot achieve it as I don`t know Python to do it for myself.

Hi Poreko,

I updated the Material Find Texture Path node in the last version of the Genius Loci package :

For your other request, unfortunately I have neither the time nor the personal interest to dive back into the part of the API devoted to materials.

Filtering out materials without textures.dyn (10.4 KB)

Thank you for your swift answer!

Alltough I did not do it clean, but since then I found a workaround the said request by adjusting the lacing of the component to longest - like this I was able to get 3 texture maps into a list per every material (if there were any). The only problem was that I could not sort between the types of maps (bitmap, bump map, cutout, etc.) but nevertheless it was already useful to see them next to their assigned materials in excel. It made it already much easier to track back the path to all textures.

Hi Alban_de Chasterigner

Your series of nodes for Materials and textures are fantasitc, thank you for this. Would I be able to ask, if a material has more than one texture applied, Image + bump map etc, can your MaterialFindTexturePath provide all of these, or is it just the Image?

Thank you for any help
Tim

1 Like

Hi Tim,

I’m glad you found the Genius Loci package useful.

Yes the node find all the textures :

1 Like

Thank you very much for this. I have been testing with the new advanced material assets [Base Material - Opaque], and this only returns the Image texture, not the Relief Pattern (Bump). Is there something obvious I am not doing correctly? Please see screencaptures below:


Thank you again for your help.
Tim

1 Like

This is indeed true.
I updated the node on Github to also get the “Bump” images.

To replace here :
C:\Users\%USERNAME%\AppData\Roaming\Dynamo\Dynamo Revit\2.10\packages\Genius Loci\dyf

3 Likes