Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEAT: Material appearance #5427

Merged
merged 3 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions src/ansys/aedt/core/modeler/cad/object_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@
self._surface_material = None
self._color = None
self._wireframe = None
self._material_appearance = None
self._part_coordinate_system = None
self._model = None
self._m_groupName = None
Expand Down Expand Up @@ -1342,6 +1343,45 @@
self._change_property(vWireframe)
self._wireframe = fWireframe

@property
def material_appearance(self):
"""Material appearance property of the part.

Returns
-------
bool
``True`` when material appearance is activated for the part, ``False`` otherwise.

References
----------

>>> oEditor.GetPropertyValue
>>> oEditor.ChangeProperty

"""
if self._material_appearance is not None:
return self._material_appearance

Check warning on line 1363 in src/ansys/aedt/core/modeler/cad/object_3d.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/modeler/cad/object_3d.py#L1363

Added line #L1363 was not covered by tests
if "Material Appearance" in self.valid_properties:
material_appearance = self._oeditor.GetPropertyValue(
"Geometry3DAttributeTab", self._m_name, "Material Appearance"
)
if material_appearance == "true" or material_appearance == "True":
self._material_appearance = True
else:
self._material_appearance = False
return self._material_appearance

@material_appearance.setter
def material_appearance(self, material_appearance):
vMaterialAppearance = [

Check warning on line 1376 in src/ansys/aedt/core/modeler/cad/object_3d.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/modeler/cad/object_3d.py#L1376

Added line #L1376 was not covered by tests
"NAME:Material Appearance",
"Value:=",
material_appearance,
]

self._change_property(vMaterialAppearance)
self._material_appearance = material_appearance

Check warning on line 1383 in src/ansys/aedt/core/modeler/cad/object_3d.py

View check run for this annotation

Codecov / codecov/patch

src/ansys/aedt/core/modeler/cad/object_3d.py#L1382-L1383

Added lines #L1382 - L1383 were not covered by tests

@pyaedt_function_handler()
def history(self):
"""Object history.
Expand Down
6 changes: 5 additions & 1 deletion src/ansys/aedt/core/modeler/cad/primitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -6311,7 +6311,11 @@ def update_geometry_property(self, assignment, name=None, value=None):
"solve_inside": {"property_name": "Solve Inside", "reset_attr": ["_solve_inside"]},
"color": {"property_name": "Color", "reset_attr": ["_color"]},
"transparency": {"property_name": "Transparent", "reset_attr": ["_transparency"]},
"part_coordinate_system": {"property_name": "Orientation", "reset_attr": ["_part_coordinate_system"]},
"part_coordinate_system": {
"property_name": "Orientation",
"reset_attr": ["_part_coordinate_system"],
},
"material_appearance": {"property_name": "Material Appearance", "reset_attr": ["_material_appearance"]},
}

# Check if property name is valid
Expand Down
2 changes: 1 addition & 1 deletion tests/system/general/test_07_Object3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,14 +241,14 @@ def test_07_object_clone_and_get_properties(self):
assert new_object.solve_inside == initial_object.solve_inside
assert new_object.model == initial_object.model
assert new_object.display_wireframe == initial_object.display_wireframe
assert new_object.material_appearance == initial_object.material_appearance
assert new_object.part_coordinate_system == initial_object.part_coordinate_system
assert new_object.transparency == 0.76
assert new_object.color == initial_object.color
assert new_object.bounding_box == initial_object.bounding_box
assert len(new_object.vertices) == 8
assert len(new_object.faces) == 6
assert len(new_object.edges) == 12
assert new_object.display_wireframe == initial_object.display_wireframe
new_object.name = "Properties_Box"
assert not new_object.name == "Properties_Box"

Expand Down
6 changes: 6 additions & 0 deletions tests/system/general/test_08_Primitives3D.py
Original file line number Diff line number Diff line change
Expand Up @@ -2071,3 +2071,9 @@ def test_95_update_geometry_property(self):
self.aedtapp.modeler.update_geometry_property([box2.name], "part_coordinate_system", cs.name)
assert box2.part_coordinate_system == cs.name
assert box1.part_coordinate_system == "Global"

self.aedtapp.modeler.update_geometry_property([box1.name], "material_appearance", True)
assert box1.material_appearance

self.aedtapp.modeler.update_geometry_property([box1.name, box2.name], "material_appearance", True)
assert box2.material_appearance
Loading