mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
Users can now specify which IFC files they want to cut
This commit is contained in:
@@ -116,6 +116,9 @@ if bpy is not None:
|
||||
operator.EyedropIfcCsv,
|
||||
operator.ReloadIfcFile,
|
||||
operator.SelectSimilarType,
|
||||
operator.AddIfcFile,
|
||||
operator.RemoveIfcFile,
|
||||
operator.SelectDocIfcFile,
|
||||
prop.StrProperty,
|
||||
prop.Classification,
|
||||
prop.ClassificationReference,
|
||||
|
||||
@@ -152,8 +152,6 @@ class IfcCutter:
|
||||
self.load_ifc_files()
|
||||
print('# Timer logged at {:.2f} seconds'.format(time.time() - start_time))
|
||||
start_time = time.time()
|
||||
print('# Get units')
|
||||
self.get_units()
|
||||
print('# Timer logged at {:.2f} seconds'.format(time.time() - start_time))
|
||||
start_time = time.time()
|
||||
print('# Get product shapes')
|
||||
@@ -189,16 +187,12 @@ class IfcCutter:
|
||||
print('# Timer logged at {:.2f} seconds'.format(time.time() - start_time))
|
||||
|
||||
def load_ifc_files(self):
|
||||
for filename in Path(self.data_dir).glob('*.ifc'):
|
||||
print('Loading file {} ...'.format(filename))
|
||||
self.ifc_files.append(ifcopenshell.open(filename))
|
||||
|
||||
def get_units(self):
|
||||
unit_assignment = self.ifc_files[0].by_type('IfcUnitAssignment')[0]
|
||||
for unit in unit_assignment.Units:
|
||||
if unit.UnitType == 'LENGTHUNIT':
|
||||
self.unit = unit
|
||||
break
|
||||
loaded_files = []
|
||||
for ifc_file in self.ifc_files:
|
||||
print('Loading file {} ...'.format(ifc_file))
|
||||
if ifc_file:
|
||||
loaded_files.append(ifcopenshell.open(ifc_file))
|
||||
self.ifc_files = loaded_files
|
||||
|
||||
def get_product_shapes(self):
|
||||
if not self.should_recut:
|
||||
@@ -699,7 +693,7 @@ class SvgWriter():
|
||||
|
||||
def calculate_scale(self):
|
||||
# TODO: properly handle units
|
||||
if self.ifc_cutter.unit.Name == 'METRE':
|
||||
if self.ifc_cutter.unit == 'METRE':
|
||||
self.scale *= 1000
|
||||
self.raw_width = self.ifc_cutter.section_box['x']
|
||||
self.raw_height = self.ifc_cutter.section_box['y']
|
||||
|
||||
@@ -1572,9 +1572,12 @@ class CutSection(bpy.types.Operator):
|
||||
y_axis = camera.matrix_world.to_quaternion() @ Vector((0, -1, 0))
|
||||
top_left_corner = location - (width / 2 * x_axis) - (height / 2 * y_axis)
|
||||
ifc_cutter = cut_ifc.IfcCutter()
|
||||
ifc_cutter.ifc_files = [i.name for i in bpy.context.scene.DocProperties.ifc_files]
|
||||
ifc_cutter.data_dir = bpy.context.scene.BIMProperties.data_dir
|
||||
ifc_cutter.diagram_name = self.diagram_name
|
||||
ifc_cutter.background_image = bpy.context.scene.render.filepath
|
||||
if bpy.context.scene.unit_settings.length_unit == 'METERS':
|
||||
ifc_cutter.unit = 'METRE'
|
||||
ifc_cutter.leader_obj = None
|
||||
ifc_cutter.stair_obj = None
|
||||
ifc_cutter.dimension_obj = None
|
||||
@@ -2319,3 +2322,37 @@ class SelectSimilarType(bpy.types.Operator):
|
||||
if obj.BIMObjectProperties.relating_type == relating_type:
|
||||
obj.select_set(True)
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
class AddIfcFile(bpy.types.Operator):
|
||||
bl_idname = 'bim.add_ifc_file'
|
||||
bl_label = 'Add IFC File'
|
||||
|
||||
def execute(self, context):
|
||||
pset = bpy.context.scene.DocProperties.ifc_files.add()
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
class RemoveIfcFile(bpy.types.Operator):
|
||||
bl_idname = 'bim.remove_ifc_file'
|
||||
bl_label = 'Remove IFC File'
|
||||
index: bpy.props.IntProperty()
|
||||
|
||||
def execute(self, context):
|
||||
bpy.context.scene.DocProperties.ifc_files.remove(self.index)
|
||||
return {'FINISHED'}
|
||||
|
||||
|
||||
class SelectDocIfcFile(bpy.types.Operator):
|
||||
bl_idname = "bim.select_doc_ifc_file"
|
||||
bl_label = "Select Documentation IFC File"
|
||||
filepath: bpy.props.StringProperty(subtype="FILE_PATH")
|
||||
index: bpy.props.IntProperty()
|
||||
|
||||
def execute(self, context):
|
||||
bpy.context.scene.DocProperties.ifc_files[self.index].name = self.filepath
|
||||
return {'FINISHED'}
|
||||
|
||||
def invoke(self, context, event):
|
||||
context.window_manager.fileselect_add(self)
|
||||
return {'RUNNING_MODAL'}
|
||||
|
||||
@@ -381,6 +381,7 @@ class DocProperties(PropertyGroup):
|
||||
available_views: EnumProperty(items=getViews, name="Available Views")
|
||||
sheet_name: StringProperty(name="Sheet Name", update=refreshSheets)
|
||||
available_sheets: EnumProperty(items=getSheets, name="Available Sheets")
|
||||
ifc_files: CollectionProperty(name='IFCs', type=StrProperty)
|
||||
|
||||
|
||||
class BIMCameraProperties(PropertyGroup):
|
||||
|
||||
@@ -533,11 +533,18 @@ class BIM_PT_documentation(Panel):
|
||||
row.operator('bim.open_sheet', icon='URL', text='')
|
||||
row.operator('bim.open_compiled_sheet', icon='OUTPUT', text='')
|
||||
|
||||
row = layout.row()
|
||||
row = layout.row(align=True)
|
||||
row.operator('bim.add_view_to_sheet')
|
||||
row.operator('bim.create_sheets')
|
||||
|
||||
row = layout.row()
|
||||
row.operator('bim.create_sheets')
|
||||
row.operator('bim.add_ifc_file')
|
||||
|
||||
for index, ifc_file in enumerate(props.ifc_files):
|
||||
row = layout.row(align=True)
|
||||
row.prop(ifc_file, 'name', text='IFC #{}'.format(index + 1))
|
||||
row.operator('bim.select_doc_ifc_file', icon='FILE_FOLDER', text='')
|
||||
row.operator('bim.remove_ifc_file', icon='X', text='').index = index
|
||||
|
||||
row = layout.row()
|
||||
row.operator('bim.generate_digital_twin')
|
||||
|
||||
Reference in New Issue
Block a user