mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-20 04:04:00 +00:00
#1153 Add support for Annotation3D representations
This commit is contained in:
@@ -206,25 +206,14 @@ class UpdateRepresentation(bpy.types.Operator):
|
||||
|
||||
new_representation = ifcopenshell.api.run("geometry.add_representation", self.file, **representation_data)
|
||||
|
||||
[
|
||||
blenderbim.core.style.add_style(tool.Ifc, tool.Style, obj=s.material)
|
||||
for s in obj.material_slots
|
||||
if s.material and not s.material.BIMMaterialProperties.ifc_style_id
|
||||
]
|
||||
|
||||
if isinstance(obj.data, bpy.types.Mesh) and len(obj.data.polygons):
|
||||
if tool.Geometry.is_body_representation(new_representation):
|
||||
[tool.Geometry.run_style_add_style(obj=mat) for mat in tool.Geometry.get_object_materials_without_styles(obj)]
|
||||
ifcopenshell.api.run(
|
||||
"style.assign_representation_styles",
|
||||
self.file,
|
||||
**{
|
||||
"shape_representation": new_representation,
|
||||
"styles": [
|
||||
self.file.by_id(s.material.BIMMaterialProperties.ifc_style_id)
|
||||
for s in obj.material_slots
|
||||
if s.material
|
||||
],
|
||||
"should_use_presentation_style_assignment": context.scene.BIMGeometryProperties.should_use_presentation_style_assignment,
|
||||
},
|
||||
shape_representation=new_representation,
|
||||
styles=tool.Geometry.get_styles(obj),
|
||||
should_use_presentation_style_assignment=context.scene.BIMGeometryProperties.should_use_presentation_style_assignment,
|
||||
)
|
||||
tool.Geometry.record_object_materials(obj)
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ def add_representation(
|
||||
profile_set_usage=profile_set_usage,
|
||||
)
|
||||
|
||||
if geometry.does_object_have_mesh_with_faces(obj):
|
||||
if geometry.is_body_representation(representation):
|
||||
[geometry.run_style_add_style(obj=mat) for mat in geometry.get_object_materials_without_styles(obj)]
|
||||
ifc.run(
|
||||
"style.assign_representation_styles",
|
||||
|
||||
@@ -206,7 +206,6 @@ class Geometry:
|
||||
def clear_scale(cls, obj): pass
|
||||
def create_dynamic_voids(cls, obj): pass
|
||||
def delete_data(cls, data): pass
|
||||
def does_object_have_mesh_with_faces(cls, obj): pass
|
||||
def does_representation_id_exist(cls, representation_id): pass
|
||||
def duplicate_object_data(cls, obj): pass
|
||||
def get_cartesian_point_coordinate_offset(cls, obj): pass
|
||||
|
||||
@@ -75,10 +75,6 @@ class Geometry(blenderbim.core.tool.Geometry):
|
||||
def delete_data(cls, data):
|
||||
bpy.data.meshes.remove(data)
|
||||
|
||||
@classmethod
|
||||
def does_object_have_mesh_with_faces(cls, obj):
|
||||
return bool(isinstance(obj.data, bpy.types.Mesh) and len(obj.data.polygons))
|
||||
|
||||
@classmethod
|
||||
def does_representation_id_exist(cls, representation_id):
|
||||
try:
|
||||
|
||||
@@ -102,25 +102,6 @@ class TestDeleteData(NewFile):
|
||||
assert not bpy.data.meshes.get("Mesh")
|
||||
|
||||
|
||||
class TestDoesObjectHaveMeshWithFaces(NewFile):
|
||||
def test_empties_return_false(self):
|
||||
obj = bpy.data.objects.new("Object", None)
|
||||
assert subject.does_object_have_mesh_with_faces(obj) is False
|
||||
|
||||
def test_non_meshes_return_false(self):
|
||||
obj = bpy.data.objects.new("Object", bpy.data.cameras.new("Curve"))
|
||||
assert subject.does_object_have_mesh_with_faces(obj) is False
|
||||
|
||||
def test_meshes_without_faces_return_false(self):
|
||||
obj = bpy.data.objects.new("Object", bpy.data.meshes.new("Mesh"))
|
||||
assert subject.does_object_have_mesh_with_faces(obj) is False
|
||||
|
||||
def test_meshes_with_faces_return_true(self):
|
||||
bpy.ops.mesh.primitive_cube_add()
|
||||
obj = bpy.data.objects.get("Cube")
|
||||
assert subject.does_object_have_mesh_with_faces(obj) is True
|
||||
|
||||
|
||||
class TestDoesRepresentationIdExist(NewFile):
|
||||
def test_run(self):
|
||||
ifc = ifcopenshell.file()
|
||||
|
||||
Reference in New Issue
Block a user