The MaterialBase module

Here's an example in which MaterialBase is used to list the attributes of the concrete custom material on a single member. This is particularly effective when a concrete custom member is selected, and it may be useful for finding the attributes of other custom materials.

SDS2 Python Prompt
# In this example, a concrete cast in place beam (member 3) is selected.
# Finds the materials in the selected member.
>>> import model
>>> import MaterialBase
>>> m = model.selected_member()
>>> m.materials
[<material 0 of member 3>, <material 1 of member 3>, <material 2 of member 3>, <material 3 of member 3>, <material 4 of member 3>, <material 5 of member 3>, <material 6 of member 3>]
# Look for the concrete material. It is found in material 0.
t = m.Material[0]
>>> t.custom_material_type
'ConcreteMaterial'
# The rest are rebar material; for example:
t = m.Material[1]
>>> t.custom_material_type
'ShapedRebar'
# Use the member number (3) followed by the material number (0) as the argument.
>>> mt_handle = MaterialBase.MaterialHandle(3, 0)
>>> mem = MaterialBase.GetMaterialLink(mt_handle, True, False)
# Prints a list of material attributes for the member.
# Shown is a partial list for clarity -- the actual list is much longer!
>>> dir(mem)
['Add', 'AutoDescription', 'CalculateDimensions', 'finish', 'finish_index', 'grade', 'id', 'is_dummy', 'no_detail', 'piecemark', 'pour_uuid', 'strength_index', 'usage', 'volume_cubic_feet', 'volume_cubic_yards']
# Returns the strength_index number.
# Index number 2 is line 3 of the Concrete Strength window.
>>> mem.strength_index
2

To get help on MaterialBase, use the built-in Python functions dir() and help() .

PR 37405 Material grade and finish are now available to the python interface through the MaterialBase class with the SetGrade/GetGrade and SetFinish/GetFinish methods.

MaterialFinishCombobox and MaterialGradeCombobox are now available in the MaterialBaseWidgets parametrics module. (v2016)

PR 45100 Calling GetPolygons() on a MaterialBase material that is not yet in the database now returns None if the material does not yet have polygons. (v2018)

PR 46769 The Python MaterialBase API allows custom materials to be set to dummy material via the 'is_dummy' attribute. (v2018)

PR 45883 Custom material surface area is now customizable by overriding the CalculateSurfaceArea() method of MaterialBase. (v2018)