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

2 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

4 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:

1 Like

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.

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.