-
Notifications
You must be signed in to change notification settings - Fork 18
pytha.find_by_attribute
fabian-flassig edited this page Jun 8, 2026
·
1 revision
Searches the model for elements carrying a given attribute value and returns their handles.
This function is located in the pytha module.
pytha.find_by_attribute(attribute, value [, element_type])| Parameter | Type | Description |
|---|---|---|
attribute |
string |
Name of the attribute to test. The attribute must exist; an unknown name raises an error. |
value |
string |
The value to match. The comparison is case-insensitive and is performed against the attribute's formatted (display) value — the same text shown in the PYTHA user interface. |
element_type |
string |
Optional. Restricts the search to one element kind: "part", "ngo" or "group". If omitted, parts, NGOs and groups are all searched. |
| Type | Description |
|---|---|
elements |
{handle, ...} |
- The match is on the formatted value string, so numeric and list attributes are compared as they are displayed, not as raw internal values.
- The search is a linear scan over all elements of the requested type(s). For large models, pass
element_typeto limit the scan. - The returned handles can be used with the usual element functions, e.g.
get_element_attribute,set_element_materialormove_element.
-- Recolour every part whose "Article" attribute is "A-1024".
local hits = pytha.find_by_attribute("Article", "A-1024", "part")
for _, part in ipairs(hits) do
pytha.set_element_material(part, "Oak")
end
-- Search parts, NGOs and groups at once.
local all = pytha.find_by_attribute("Status", "approved")Minimum PYTHA Version: V27
pytha, Attributes Functions, get_element_attribute, get_attribute_list_values, enumerate_parts, Attributes