mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
Allow you to specify whether to recut all, or just recut selected. See #901.
This commit is contained in:
@@ -128,6 +128,8 @@ class IfcCutter:
|
||||
self.metadata_pickle_file = 'metadata.pickle'
|
||||
self.cut_pickle_file = 'cut.pickle'
|
||||
self.should_recut = True
|
||||
self.should_recut_selected = True
|
||||
self.selected_global_ids = []
|
||||
self.should_extract = True
|
||||
self.diagram_name = None
|
||||
self.background_image = None
|
||||
@@ -250,7 +252,7 @@ class IfcCutter:
|
||||
shape_pickle = os.path.join(
|
||||
self.data_dir, 'cache', 'shapes', '{}.pickle'.format(os.path.basename(filename)))
|
||||
shape_map = {}
|
||||
if os.path.isfile(shape_pickle):
|
||||
if self.should_recut_selected and os.path.isfile(shape_pickle):
|
||||
with open(shape_pickle, 'rb') as shape_file:
|
||||
shape_map = pickle.load(shape_file)
|
||||
|
||||
@@ -266,7 +268,11 @@ class IfcCutter:
|
||||
or self.has_annotation(product):
|
||||
continue
|
||||
try:
|
||||
if product.GlobalId in shape_map:
|
||||
if self.should_recut_selected \
|
||||
and product.GlobalId in self.selected_global_ids:
|
||||
shape = ifcopenshell.geom.create_shape(settings, product).geometry
|
||||
shape_map[product.GlobalId] = shape
|
||||
elif product.GlobalId in shape_map:
|
||||
shape = shape_map[product.GlobalId]
|
||||
else:
|
||||
shape = ifcopenshell.geom.create_shape(settings, product).geometry
|
||||
|
||||
@@ -2011,6 +2011,16 @@ class CutSection(bpy.types.Operator):
|
||||
ifc_cutter.text_pickle_file = os.path.join(ifc_cutter.data_dir, '{}-text.pickle'.format(self.diagram_name))
|
||||
ifc_cutter.metadata_pickle_file = os.path.join(ifc_cutter.data_dir, '{}-metadata.pickle'.format(self.diagram_name))
|
||||
ifc_cutter.should_recut = bpy.context.scene.DocProperties.should_recut
|
||||
ifc_cutter.should_recut_selected = bpy.context.scene.DocProperties.should_recut_selected
|
||||
selected_global_ids = []
|
||||
for obj in bpy.context.selected_objects:
|
||||
if 'Ifc' not in obj.name:
|
||||
continue
|
||||
for attribute in obj.BIMObjectProperties.attributes:
|
||||
if attribute.name == 'GlobalId':
|
||||
selected_global_ids.append(attribute.string_value)
|
||||
break
|
||||
ifc_cutter.selected_global_ids = selected_global_ids
|
||||
ifc_cutter.should_extract = bpy.context.scene.DocProperties.should_extract
|
||||
svg_writer = svgwriter.SvgWriter(ifc_cutter)
|
||||
numerator, denominator = camera.data.BIMCameraProperties.diagram_scale.split(':')
|
||||
|
||||
@@ -394,6 +394,7 @@ class Subcontext(PropertyGroup):
|
||||
|
||||
class DocProperties(PropertyGroup):
|
||||
should_recut: BoolProperty(name="Should Recut", default=True)
|
||||
should_recut_selected: BoolProperty(name="Should Recut Selected Only", default=False)
|
||||
should_render: BoolProperty(name="Should Render", default=True)
|
||||
should_extract: BoolProperty(name="Should Extract", default=True)
|
||||
view_name: StringProperty(name="View Name")
|
||||
|
||||
@@ -785,6 +785,8 @@ class BIM_PT_camera(Panel):
|
||||
row = layout.row()
|
||||
row.prop(dprops, 'should_recut')
|
||||
row = layout.row()
|
||||
row.prop(dprops, 'should_recut_selected')
|
||||
row = layout.row()
|
||||
row.prop(dprops, 'should_render')
|
||||
row = layout.row()
|
||||
row.prop(dprops, 'should_extract')
|
||||
|
||||
Reference in New Issue
Block a user