Skill: Robust Material Resolution
This skill provides a standardized method for resolving physical material names from Revit snapshots. It addresses the common issue where text-based "Material" parameters are empty, inconsistent, or hold internal Type names instead of physical material identities.
1. Core Logic & Assumptions
ElementId Referencing
In Revit, the Material parameter typically stores the ElementId of a Material element, not a string. This skill assumes that the true material name is stored in the Name parameter of the associated Material element.
Join Hierarchy
- •Identify the parameter ID for "Material" on the host element.
- •Extract the
value_int(ElementId) from that parameter. - •Join this ID to the
elements_globaltable to find the Material element. - •Join the
Nameparameter ID from theparameter_catalog_globalto extract the final string.
2. Standard SQL Template (Global Scoped)
sql
SELECT
e.document_id,
e.element_id,
mat_name.value_string as ResolvedMaterial
FROM elements_global e
-- 1. Get the Material ElementId from the host
JOIN element_parameters_global ep_ref ON e.document_id = ep_ref.document_id AND e.element_id = ep_ref.element_id
AND ep_ref.parameter_id = (SELECT parameter_id FROM parameter_catalog_global WHERE parameter_name = 'Material' LIMIT 1)
-- 2. Join to the Material Element's 'Name' parameter
JOIN element_parameters_global mat_name ON ep_ref.document_id = mat_name.document_id AND ep_ref.value_int = mat_name.element_id
AND mat_name.parameter_id = (SELECT parameter_id FROM parameter_catalog_global WHERE parameter_name = 'Name' LIMIT 1)
WHERE e.category_name = '{CATEGORY_NAME}'
LIMIT 100
3. Best Practices for Developers
- •Token Efficiency: Material joins can be expensive. Always use
DISTINCTorGROUP BYwhen performing takeoffs to minimize the result size. - •Parameter Lookup: Use
(SELECT parameter_id FROM parameter_catalog_global WHERE parameter_name = '...' LIMIT 1)instead of hardcoded negative IDs to ensure compatibility across different snapshot versions. - •Scoping: Always include
document_idin joins to prevent cross-model data contamination.
4. When to use this skill
- •When "Pipe Material" or "Wall Material" parameters return empty strings or numeric IDs.
- •For specialized takeoffs where the exact physical substance (e.g., "Concrete - Cast-in-Place Gray") is required.
5. When NOT to use this skill
- •When the
type_nameorfamily_nameis sufficient for the user's request. - •When querying non-physical elements (e.g., Views, Sheets, Schedules).