mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-23 12:32:39 +00:00
black format, cleanup, notes
bim.generate_global_id - forgot to remove it previously, this operator isn't intended for debug section
This commit is contained in:
@@ -102,6 +102,8 @@ class IfcExporter:
|
|||||||
if result:
|
if result:
|
||||||
results.append(result)
|
results.append(result)
|
||||||
result = self.sync_object_material(obj)
|
result = self.sync_object_material(obj)
|
||||||
|
# TODO: sync_object_material always returns None
|
||||||
|
# so it's never really appended
|
||||||
if result:
|
if result:
|
||||||
results.append(result)
|
results.append(result)
|
||||||
except ReferenceError:
|
except ReferenceError:
|
||||||
@@ -142,7 +144,6 @@ class IfcExporter:
|
|||||||
element = self.file.by_id(obj.BIMObjectProperties.ifc_definition_id)
|
element = self.file.by_id(obj.BIMObjectProperties.ifc_definition_id)
|
||||||
if not tool.Ifc.is_moved(obj):
|
if not tool.Ifc.is_moved(obj):
|
||||||
return
|
return
|
||||||
blender_matrix = np.array(obj.matrix_world)
|
|
||||||
if (obj.scale - Vector((1.0, 1.0, 1.0))).length > 1e-4:
|
if (obj.scale - Vector((1.0, 1.0, 1.0))).length > 1e-4:
|
||||||
bpy.ops.bim.update_representation(obj=obj.name)
|
bpy.ops.bim.update_representation(obj=obj.name)
|
||||||
return element
|
return element
|
||||||
|
|||||||
@@ -75,9 +75,6 @@ class BIM_PT_debug(Panel):
|
|||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.operator("bim.profile_import_ifc")
|
row.operator("bim.profile_import_ifc")
|
||||||
|
|
||||||
row = layout.row()
|
|
||||||
row.operator("bim.generate_global_id")
|
|
||||||
|
|
||||||
row = layout.split(factor=0.5, align=True)
|
row = layout.split(factor=0.5, align=True)
|
||||||
row.operator("bim.create_shape_from_step_id").should_include_curves = False
|
row.operator("bim.create_shape_from_step_id").should_include_curves = False
|
||||||
row.operator("bim.create_shape_from_step_id", text="", icon="IPO_ELASTIC").should_include_curves = True
|
row.operator("bim.create_shape_from_step_id", text="", icon="IPO_ELASTIC").should_include_curves = True
|
||||||
|
|||||||
@@ -512,6 +512,7 @@ class CreateDrawing(bpy.types.Operator):
|
|||||||
|
|
||||||
for ifc_path, ifc in files.items():
|
for ifc_path, ifc in files.items():
|
||||||
# Don't use draw.main() just whilst we're prototyping and experimenting
|
# Don't use draw.main() just whilst we're prototyping and experimenting
|
||||||
|
# TODO: hash paths are never used
|
||||||
ifc_hash = hashlib.md5(ifc_path.encode("utf-8")).hexdigest()
|
ifc_hash = hashlib.md5(ifc_path.encode("utf-8")).hexdigest()
|
||||||
ifc_cache_path = os.path.join(context.scene.BIMProperties.data_dir, "cache", f"{ifc_hash}.h5")
|
ifc_cache_path = os.path.join(context.scene.BIMProperties.data_dir, "cache", f"{ifc_hash}.h5")
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
|
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
import blenderbim.core.style
|
|
||||||
from typing import TYPE_CHECKING, Optional
|
from typing import TYPE_CHECKING, Optional
|
||||||
import blenderbim.core.tool as tool
|
import blenderbim.core.tool as tool
|
||||||
|
|
||||||
@@ -200,23 +199,25 @@ def select_connection(geometry, connection=None):
|
|||||||
def remove_connection(geometry, connection=None):
|
def remove_connection(geometry, connection=None):
|
||||||
geometry.remove_connection(connection)
|
geometry.remove_connection(connection)
|
||||||
|
|
||||||
|
|
||||||
def get_similar_openings(ifc, opening):
|
def get_similar_openings(ifc, opening):
|
||||||
model = ifc.get()
|
model = ifc.get()
|
||||||
all_openings = model.by_type("IfcOpeningElement")
|
all_openings = model.by_type("IfcOpeningElement")
|
||||||
similar_openings = [o for o in all_openings if o.ObjectPlacement == opening.ObjectPlacement and o != opening]
|
similar_openings = [o for o in all_openings if o.ObjectPlacement == opening.ObjectPlacement and o != opening]
|
||||||
return similar_openings
|
return similar_openings
|
||||||
|
|
||||||
|
|
||||||
def get_similar_openings_building_objs(ifc, similar_openings):
|
def get_similar_openings_building_objs(ifc, similar_openings):
|
||||||
building_objs = []
|
building_objs = []
|
||||||
for similar_opening in similar_openings:
|
for similar_opening in similar_openings:
|
||||||
building_objs.append(ifc.get_object(similar_opening.VoidsElements[0].RelatingBuildingElement))
|
building_objs.append(ifc.get_object(similar_opening.VoidsElements[0].RelatingBuildingElement))
|
||||||
return building_objs
|
return building_objs
|
||||||
|
|
||||||
def edit_similar_opening_placement(geometry, opening = None, similar_openings = None):
|
|
||||||
|
def edit_similar_opening_placement(geometry, opening=None, similar_openings=None):
|
||||||
if not opening or not similar_openings:
|
if not opening or not similar_openings:
|
||||||
return
|
return
|
||||||
for similar_opening in similar_openings:
|
for similar_opening in similar_openings:
|
||||||
old_placement = similar_opening.ObjectPlacement
|
old_placement = similar_opening.ObjectPlacement
|
||||||
similar_opening.ObjectPlacement = opening.ObjectPlacement
|
similar_opening.ObjectPlacement = opening.ObjectPlacement
|
||||||
geometry.delete_opening_object_placement(old_placement)
|
geometry.delete_opening_object_placement(old_placement)
|
||||||
|
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ def select_decomposed_elements(spatial):
|
|||||||
spatial.select_products(spatial.get_decomposed_elements(container))
|
spatial.select_products(spatial.get_decomposed_elements(container))
|
||||||
|
|
||||||
|
|
||||||
#HERE STARTS SPATIAL TOOL
|
# HERE STARTS SPATIAL TOOL
|
||||||
def generate_space(ifc, spatial, model, Type):
|
def generate_space(ifc, spatial, model, Type):
|
||||||
active_obj = spatial.get_active_obj()
|
active_obj = spatial.get_active_obj()
|
||||||
selected_objects = spatial.get_selected_objects()
|
selected_objects = spatial.get_selected_objects()
|
||||||
@@ -164,21 +164,20 @@ def generate_space(ifc, spatial, model, Type):
|
|||||||
relating_type = None
|
relating_type = None
|
||||||
|
|
||||||
if selected_objects and active_obj:
|
if selected_objects and active_obj:
|
||||||
x, y, z, h, mat = spatial.get_x_y_z_h_mat_from_active_obj(active_obj) ##mat
|
x, y, z, h, mat = spatial.get_x_y_z_h_mat_from_active_obj(active_obj) ##mat
|
||||||
element = ifc.get_entity(active_obj)
|
element = ifc.get_entity(active_obj)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
x, y, z, h, mat = spatial.get_x_y_z_h_mat_from_cursor() ##mat
|
x, y, z, h, mat = spatial.get_x_y_z_h_mat_from_cursor() ##mat
|
||||||
|
|
||||||
|
|
||||||
space_polygon = spatial.get_space_polygon_from_context_visible_objects(x, y)
|
space_polygon = spatial.get_space_polygon_from_context_visible_objects(x, y)
|
||||||
|
|
||||||
if not space_polygon:
|
if not space_polygon:
|
||||||
return
|
return
|
||||||
|
|
||||||
bm = spatial.get_bmesh_from_polygon(space_polygon, h=h) ##mat
|
bm = spatial.get_bmesh_from_polygon(space_polygon, h=h) ##mat
|
||||||
|
|
||||||
mesh = spatial.get_named_mesh_from_bmesh(name = "Space", bmesh = bm)
|
mesh = spatial.get_named_mesh_from_bmesh(name="Space", bmesh=bm)
|
||||||
|
|
||||||
if element and element.is_a("IfcSpace"):
|
if element and element.is_a("IfcSpace"):
|
||||||
mesh = spatial.get_transformed_mesh_from_local_to_global(mesh)
|
mesh = spatial.get_transformed_mesh_from_local_to_global(mesh)
|
||||||
@@ -199,6 +198,7 @@ def generate_space(ifc, spatial, model, Type):
|
|||||||
if relating_type:
|
if relating_type:
|
||||||
spatial.assign_relating_type_to_element(ifc, Type, element, relating_type)
|
spatial.assign_relating_type_to_element(ifc, Type, element, relating_type)
|
||||||
|
|
||||||
|
|
||||||
def generate_spaces_from_walls(ifc, spatial, collector):
|
def generate_spaces_from_walls(ifc, spatial, collector):
|
||||||
z = spatial.get_active_obj_z()
|
z = spatial.get_active_obj_z()
|
||||||
h = spatial.get_active_obj_height()
|
h = spatial.get_active_obj_height()
|
||||||
@@ -212,7 +212,7 @@ def generate_spaces_from_walls(ifc, spatial, collector):
|
|||||||
|
|
||||||
name = "Space" + str(i)
|
name = "Space" + str(i)
|
||||||
|
|
||||||
obj = spatial.get_named_obj_from_bmesh(name, bmesh = bm)
|
obj = spatial.get_named_obj_from_bmesh(name, bmesh=bm)
|
||||||
|
|
||||||
spatial.set_obj_origin_to_bboxcenter(obj)
|
spatial.set_obj_origin_to_bboxcenter(obj)
|
||||||
spatial.traslate_obj_to_z_location(obj, z)
|
spatial.traslate_obj_to_z_location(obj, z)
|
||||||
@@ -230,6 +230,7 @@ def toggle_space_visibility(ifc, spatial):
|
|||||||
return
|
return
|
||||||
spatial.toggle_spaces_visibility_wired_and_textured(spaces)
|
spatial.toggle_spaces_visibility_wired_and_textured(spaces)
|
||||||
|
|
||||||
|
|
||||||
def toggle_hide_spaces(ifc, spatial):
|
def toggle_hide_spaces(ifc, spatial):
|
||||||
model = ifc.get()
|
model = ifc.get()
|
||||||
spaces = model.by_type("IfcSpace")
|
spaces = model.by_type("IfcSpace")
|
||||||
|
|||||||
Reference in New Issue
Block a user