示例#1
0
 def store_delete(self, element):
     inverses = {}
     if self.is_batched:
         if element.id() not in self.batch_delete_ids:
             self.batch_inverses.append(self.get_element_inverses(element))
         self.batch_delete_ids.add(element.id())
     else:
         inverses = self.get_element_inverses(element)
     self.operations.append({
         "action": "delete",
         "inverses": inverses,
         "value": self.serialise_entity_instance(element)
     })
示例#2
0
def regenerate_profile_usage(usecase_path, ifc_file, settings):
    elements = []
    if ifc_file.schema == "IFC2X3":
        for rel in ifc_file.get_inverse(settings["usage"]):
            if not rel.is_a("IfcRelAssociatesMaterial"):
                continue
            for element in rel.RelatedObjects:
                elements.append(element)
    else:
        for rel in settings["usage"].AssociatedTo:
            for element in rel.RelatedObjects:
                elements.append(element)

    for element in elements:
        obj = IfcStore.get_element(element.id())
        if not obj:
            continue
        representation = ifcopenshell.util.representation.get_representation(
            element, "Model", "Body", "MODEL_VIEW")
        if representation:
            blenderbim.core.geometry.switch_representation(
                tool.Geometry,
                obj=obj,
                representation=representation,
                should_reload=True,
                enable_dynamic_voids=True,
                is_global=True,
                should_sync_changes_first=False,
            )
示例#3
0
 def patch(self):
     deleted = []
     hashes = {}
     for element in self.file:
         if element.is_a('IfcRoot'):
             continue
         h = hash(tuple(element))
         if h in hashes:
             for inverse in self.file.get_inverse(element):
                 ifcopenshell.util.element.replace_attribute(
                     inverse, element, hashes[h])
             deleted.append(element.id())
         else:
             hashes[h] = element
     deleted.sort()
     deleted_q = deque(deleted)
     new = ''
     for line in self.file.wrapped_data.to_string().split('\n'):
         try:
             if int(line.split('=')[0][1:]) != deleted_q[0]:
                 new += (line + '\n')
             else:
                 deleted_q.popleft()
         except:
             new += (line + '\n')
     self.file = new
示例#4
0
    def change_thickness(self, element, thickness):
        obj = IfcStore.get_element(element.id())
        if not obj:
            return

        delta_thickness = (thickness * self.unit_scale) - obj.dimensions.y
        if round(delta_thickness, 2) == 0:
            return

        bm = bmesh.new()
        bm.from_mesh(obj.data)
        bmesh.ops.dissolve_limit(bm,
                                 angle_limit=pi / 180 * 1,
                                 verts=bm.verts,
                                 edges=bm.edges)

        min_face, max_face = self.get_wall_end_faces(obj, bm)

        verts_to_move = []
        verts_to_move.extend(self.thicken_face(min_face, delta_thickness))
        verts_to_move.extend(self.thicken_face(max_face, delta_thickness))
        for vert_to_move in verts_to_move:
            vert_to_move["vert"].co += vert_to_move["vector"]

        bm.to_mesh(obj.data)
        obj.data.update()
        bm.free()
        IfcStore.edited_objs.add(obj)
示例#5
0
 def store_create(self, element):
     if element.id():
         self.operations.append({
             "action":
             "create",
             "value":
             self.serialise_entity_instance(element)
         })
示例#6
0
 def contexts(cls):
     results = []
     for element in tool.Ifc.get().by_type(
             "IfcGeometricRepresentationContext", include_subtypes=False):
         results.append((str(element.id()), element.ContextType
                         or "Unnamed", ""))
     for element in tool.Ifc.get().by_type(
             "IfcGeometricRepresentationSubContext",
             include_subtypes=False):
         results.append((
             str(element.id()),
             "{}/{}/{}".format(
                 element.ContextType or "Unnamed",
                 element.ContextIdentifier or "Unnamed",
                 element.TargetView or "Unnamed",
             ),
             "",
         ))
     return results
示例#7
0
    def change_thickness(self, element, thickness):
        obj = IfcStore.get_element(element.id())
        if not obj:
            return

        delta_thickness = (thickness * self.unit_scale) - obj.dimensions.z
        if round(delta_thickness, 2) == 0:
            return

        modifier = ensure_solidify_modifier(obj)
        modifier.thickness += delta_thickness
        obj.location[2] -= delta_thickness
示例#8
0
 def store_edit(self, element, index, value):
     self.operations.append({
         "action":
         "edit",
         "id":
         element.id(),
         "index":
         index,
         "old":
         self.serialise_value(element, element[index]),
         "new":
         self.serialise_value(element, value),
     })
示例#9
0
 def test_creating_an_entity(self):
     element = self.file.create_entity("IfcPerson")
     assert element.is_a("IfcPerson")
     element = self.file.create_entity("IfcPerson", "identification")
     assert element.Identification == "identification"
     element = self.file.create_entity("IfcPerson",
                                       Identification="identification")
     assert element.Identification == "identification"
     element = self.file.create_entity("IfcPerson",
                                       Identification="identification",
                                       id=42)
     assert element.id() == 42
     element = self.file.createIfcPerson()
     assert element.is_a("IfcPerson")
示例#10
0
 def change_profile(self, element):
     obj = IfcStore.get_element(element.id())
     if not obj:
         return
     representation = ifcopenshell.util.representation.get_representation(
         element, "Model", "Body", "MODEL_VIEW")
     if representation:
         blenderbim.core.geometry.switch_representation(
             tool.Geometry,
             obj=obj,
             representation=representation,
             should_reload=True,
             enable_dynamic_voids=True,
             is_global=True,
             should_sync_changes_first=False,
         )
 def get_material_name(self, element):
     if hasattr(element, "Name") and element.Name:
         return element.Name
     return element.id()
示例#12
0
 def remove_filling(self, element):
     obj = IfcStore.get_element(element.id())
     bpy.ops.bim.remove_filling(obj=obj.name)
示例#13
0
 def delete_opening_element(self, element):
     obj = IfcStore.get_element(element.VoidsElements[0].RelatingBuildingElement.id())
     bpy.ops.bim.remove_opening(opening_id=element.id(), obj=obj.name)
示例#14
0
 def sync_object(self, element):
     obj = IfcStore.get_element(element.id())
     if not obj or obj not in IfcStore.edited_objs:
         return
     bpy.ops.bim.update_representation(obj=obj.name)