mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-23 09:02:44 +00:00
Fix representation where removing a representation left objects with an empty mesh. Now a proper empty is used.
This commit is contained in:
@@ -76,6 +76,14 @@ class Geometry(blenderbim.core.tool.Geometry):
|
||||
)
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def get_element_type(cls, element):
|
||||
return ifcopenshell.util.element.get_type(element)
|
||||
|
||||
@classmethod
|
||||
def get_elements_of_type(cls, type):
|
||||
return ifcopenshell.util.element.get_types(type)
|
||||
|
||||
@classmethod
|
||||
def get_ifc_representation_class(cls, element, representation):
|
||||
material = ifcopenshell.util.element.get_material(element)
|
||||
@@ -124,6 +132,10 @@ class Geometry(blenderbim.core.tool.Geometry):
|
||||
def get_total_representation_items(cls, obj):
|
||||
return max(1, len(obj.material_slots))
|
||||
|
||||
@classmethod
|
||||
def has_data_users(cls, data):
|
||||
return data.users != 0
|
||||
|
||||
@classmethod
|
||||
def import_representation(cls, obj, representation, enable_dynamic_voids=False):
|
||||
logger = logging.getLogger("ImportIFC")
|
||||
@@ -152,6 +164,14 @@ class Geometry(blenderbim.core.tool.Geometry):
|
||||
def is_body_representation(cls, representation):
|
||||
return representation.ContextOfItems.ContextIdentifier == "Body"
|
||||
|
||||
@classmethod
|
||||
def is_mapped_representation(cls, representation):
|
||||
return representation.RepresentationType == "MappedRepresentation"
|
||||
|
||||
@classmethod
|
||||
def is_type_product(cls, element):
|
||||
return element.is_a("IfcTypeProduct")
|
||||
|
||||
@classmethod
|
||||
def link(cls, element, obj):
|
||||
obj.BIMMeshProperties.ifc_definition_id = element.id()
|
||||
@@ -160,6 +180,20 @@ class Geometry(blenderbim.core.tool.Geometry):
|
||||
def rename_object(cls, obj, name):
|
||||
obj.name = name
|
||||
|
||||
@classmethod
|
||||
def replace_object_with_empty(cls, obj):
|
||||
element = tool.Ifc.get_entity(obj)
|
||||
name = obj.name
|
||||
tool.Ifc.unlink(obj)
|
||||
obj.name = ifcopenshell.guid.new()
|
||||
new_obj = bpy.data.objects.new(name, None)
|
||||
if element:
|
||||
tool.Ifc.link(element, new_obj)
|
||||
for collection in obj.users_collection:
|
||||
collection.objects.link(new_obj)
|
||||
new_obj.matrix_world = obj.matrix_world
|
||||
bpy.data.objects.remove(obj)
|
||||
|
||||
@classmethod
|
||||
def resolve_mapped_representation(cls, representation):
|
||||
if representation.RepresentationType == "MappedRepresentation":
|
||||
|
||||
Reference in New Issue
Block a user