MCPcopy
hub / github.com/CadQuery/cadquery / _get_material

Function _get_material

cadquery/occ_impl/importers/assembly.py:47–76  ·  view source on GitHub ↗

Helper to get the material for a given label.

(label: TDF_Label)

Source from the content-addressed store, hash-verified

45
46
47def _get_material(label: TDF_Label) -> Material | None:
48 """
49 Helper to get the material for a given label.
50 """
51
52 rv = None
53
54 material_ref_guid = XCAFDoc.MaterialRefGUID_s()
55
56 if label.IsAttribute(material_ref_guid):
57 attr = TDataStd_TreeNode()
58 label.FindAttribute(material_ref_guid, attr)
59 material_label = attr.Father().Label()
60
61 material_attr = XCAFDoc_Material()
62
63 material_label.FindAttribute(XCAFDoc_Material.GetID_s(), material_attr)
64 name = material_attr.GetName().ToCString()
65 description = material_attr.GetDescription().ToCString()
66 density = material_attr.GetDensity()
67 density_unit = material_attr.GetDensValType().ToCString()
68
69 rv = Material(
70 name=name,
71 description=description,
72 density=density,
73 densityUnit=density_unit,
74 )
75
76 return rv
77
78
79def _get_ref_color(label: TDF_Label) -> Color | None:

Callers 1

_process_labelFunction · 0.85

Calls 1

MaterialClass · 0.85

Tested by

no test coverage detected