Find the index of a material in the Structure

Hello all,

I’m new with python (and dynamo to be true), so i need some help to finish my script.

I’m using dynamo to adapt some elements of my library:

And here is my code:

# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)

clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

# The inputs to this node will be stored as a list in the IN variables.
ListMaterial = IN[0]
ListThickness = IN[1]
Matname = IN[2]
ListIndex = IN[3]


found_materials = []
for i, material in enumerate(ListMaterial):
	if Matname in material:
		found_materials.append(i)
		


found_thickness = [ListThickness[i] for i in found_materials]
found_index = [ListIndex[i] for i in found_materials]


adapt_mat = []
adapt_index = []
for i, thickness in enumerate(found_thickness):
	if thickness > 50:
		adapt_mat.append(found_materials[i])
		adapt_index.append(ListIndex[found_materials[i]])


# Assign your output to the OUT variable.
OUT = [adapt_mat,adapt_index]

adapt_index returns the list of all the index, not the index where the material is.
Here we can this the result for the element 225 should be 1.
How can i obtain this ?

thx by advance for the help

@olivier.petitRJ8B3 ,

whats your aim?

getting items or sorting them?

designScript can that also do!

KR

Andreas

My aim is the change “Cement screed F5” material by “Cement screed” where the thickness is upper 50.

So i try to find the id in the structure material to adapt it.

@olivier.petitRJ8B3 ,


Thx for helping !

1 Like