OSArch Community

Loosing representation while copying in ifcopenshell

  1. A

    I'm trying to copy elements using ifcopenshell.util.element.copy. I find that the Representation of the original element (for Mapped tessellated items) are lost. The new element created as the copy, however, has all the representation of the original element. This is my code that I have used to create the element copy. Is this a bug? or am I doing something wrong?

    `def create_element_copy(elements):

    z_translation = 3700
    
    for ele in elements:
    
        copied_ele = ifcopenshell.util.element.copy(f, ele)
    
        ele_container_name = int((ele.ContainedInStructure[0].RelatingStructure.Name).split('_')[-1])
    
        copied_ele_container = [_ for _ in f.by_type('IfcBuildingStorey') if _.Name == f'LEVEL_{ele_container_name+1}'][0]
    
        ifcopenshell.api.run('spatial.assign_container', f, product=copied_ele, relating_structure=copied_ele_container)
    
        copied_ele_plc = ifcopenshell.util.placement.get_local_placement(copied_ele.ObjectPlacement)
    
        copied_ele_plc[:,3][2] += z_translation
    
        matrix = mathutils.Matrix(copied_ele_plc)
    
        ifcopenshell.api.run('geometry.edit_object_placement', f, matrix=matrix, is_si=False, product=copied_ele)
    
        ifcopenshell.api.run('type.assign_type', f, related_object=copied_ele, relating_type=ele.IsTypedBy[0].RelatingType)`

Login or Register to reply.