-
Notifications
You must be signed in to change notification settings - Fork 18
pytha.get_element_material
fabian-flassig edited this page Jul 8, 2026
·
1 revision
Returns the material assigned to a part.
Retrieves the classic (face-independent) material of the given part as an element handle. Returns nil if the part has no material assigned or the assigned material can no longer be resolved.
pytha.get_element_material(element)| Parameter | Type | Description |
|---|---|---|
element |
element_handle |
Handle to a part (type "part"). |
Return value:
| Type | Description |
|---|---|
element_handle |
An element handle of type "material" for the part's assigned material, or nil if none is assigned. |
Notes:
- This function returns the part's classic material — the single material assigned to the whole part. Per-face materials are not exposed.
- The returned handle can be passed directly to
set_element_attributes,get_element_attribute, orset_element_name.
Example:
Read the material of a selected part and print its name:
local sel = pytha.get_selection()
if #sel > 0 then
local mat = pytha.get_element_material(sel[1])
if mat then
print("Material:", pytha.get_element_name(mat))
else
print("No material assigned.")
end
endCopy the material from one part to another:
local src, dst = parts[1], parts[2]
local mat = pytha.get_element_material(src)
if mat then
pytha.set_element_material(dst, mat)
endMinimum PYTHA Version: V27
See also:
pytha, element handles, set_element_material, create_material, find_material, get_element_attribute