mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-10-02 13:04:49 +00:00
#1153 Drawing layers (underlay, linework, annotation) are now per drawing instead of global
This commit is contained in:
@@ -1682,6 +1682,12 @@ class IfcImporter:
|
|||||||
else:
|
else:
|
||||||
camera.BIMCameraProperties.diagram_scale = "CUSTOM"
|
camera.BIMCameraProperties.diagram_scale = "CUSTOM"
|
||||||
camera.BIMCameraProperties.custom_diagram_scale = pset["Scale"]
|
camera.BIMCameraProperties.custom_diagram_scale = pset["Scale"]
|
||||||
|
if "HasUnderlay" in pset:
|
||||||
|
camera.BIMCameraProperties.has_underlay = pset["HasUnderlay"]
|
||||||
|
if "HasLinework" in pset:
|
||||||
|
camera.BIMCameraProperties.has_linework = pset["HasLinework"]
|
||||||
|
if "HasAnnotation" in pset:
|
||||||
|
camera.BIMCameraProperties.has_annotation = pset["HasAnnotation"]
|
||||||
return camera
|
return camera
|
||||||
|
|
||||||
def create_curve(self, element, shape):
|
def create_curve(self, element, shape):
|
||||||
|
|||||||
@@ -119,9 +119,10 @@ class CreateDrawing(bpy.types.Operator):
|
|||||||
start = time.time()
|
start = time.time()
|
||||||
self.profile_code("Start drawing generation process")
|
self.profile_code("Start drawing generation process")
|
||||||
self.props = context.scene.DocProperties
|
self.props = context.scene.DocProperties
|
||||||
|
self.cprops = self.camera.data.BIMCameraProperties
|
||||||
self.drawing_name = self.file.by_id(self.camera.BIMObjectProperties.ifc_definition_id).Name
|
self.drawing_name = self.file.by_id(self.camera.BIMObjectProperties.ifc_definition_id).Name
|
||||||
self.get_scale()
|
self.get_scale()
|
||||||
if self.camera.data.BIMCameraProperties.update_representation(self.camera):
|
if self.cprops.update_representation(self.camera):
|
||||||
bpy.ops.bim.update_representation(obj=self.camera.name, ifc_representation_class="")
|
bpy.ops.bim.update_representation(obj=self.camera.name, ifc_representation_class="")
|
||||||
underlay_svg = self.generate_underlay(context)
|
underlay_svg = self.generate_underlay(context)
|
||||||
self.profile_code("Generate underlay")
|
self.profile_code("Generate underlay")
|
||||||
@@ -186,12 +187,12 @@ class CreateDrawing(bpy.types.Operator):
|
|||||||
return svg_path
|
return svg_path
|
||||||
|
|
||||||
def generate_underlay(self, context):
|
def generate_underlay(self, context):
|
||||||
if not self.props.has_underlay:
|
if not self.cprops.has_underlay:
|
||||||
return
|
return
|
||||||
svg_path = os.path.join(context.scene.BIMProperties.data_dir, "cache", self.drawing_name + "-underlay.svg")
|
svg_path = os.path.join(context.scene.BIMProperties.data_dir, "cache", self.drawing_name + "-underlay.svg")
|
||||||
context.scene.render.filepath = svg_path[0:-4] + ".png"
|
context.scene.render.filepath = svg_path[0:-4] + ".png"
|
||||||
drawing_style = context.scene.DocProperties.drawing_styles[
|
drawing_style = context.scene.DocProperties.drawing_styles[
|
||||||
self.camera.data.BIMCameraProperties.active_drawing_style_index
|
self.cprops.active_drawing_style_index
|
||||||
]
|
]
|
||||||
|
|
||||||
if drawing_style.render_type == "DEFAULT":
|
if drawing_style.render_type == "DEFAULT":
|
||||||
@@ -246,7 +247,7 @@ class CreateDrawing(bpy.types.Operator):
|
|||||||
return svg_path
|
return svg_path
|
||||||
|
|
||||||
def generate_linework(self, context):
|
def generate_linework(self, context):
|
||||||
if not self.props.has_linework:
|
if not self.cprops.has_linework:
|
||||||
return
|
return
|
||||||
svg_path = os.path.join(context.scene.BIMProperties.data_dir, "cache", self.drawing_name + "-linework.svg")
|
svg_path = os.path.join(context.scene.BIMProperties.data_dir, "cache", self.drawing_name + "-linework.svg")
|
||||||
if os.path.isfile(svg_path) and self.props.should_use_linework_cache:
|
if os.path.isfile(svg_path) and self.props.should_use_linework_cache:
|
||||||
@@ -410,7 +411,7 @@ class CreateDrawing(bpy.types.Operator):
|
|||||||
return re.sub("[^0-9a-zA-Z]+", "", name)
|
return re.sub("[^0-9a-zA-Z]+", "", name)
|
||||||
|
|
||||||
def generate_annotation(self, context):
|
def generate_annotation(self, context):
|
||||||
if not self.props.has_annotation:
|
if not self.cprops.has_annotation:
|
||||||
return
|
return
|
||||||
svg_path = os.path.join(context.scene.BIMProperties.data_dir, "cache", self.drawing_name + "-annotation.svg")
|
svg_path = os.path.join(context.scene.BIMProperties.data_dir, "cache", self.drawing_name + "-annotation.svg")
|
||||||
if os.path.isfile(svg_path) and self.props.should_use_annotation_cache:
|
if os.path.isfile(svg_path) and self.props.should_use_annotation_cache:
|
||||||
@@ -420,7 +421,7 @@ class CreateDrawing(bpy.types.Operator):
|
|||||||
svg_writer = svgwriter.SvgWriter()
|
svg_writer = svgwriter.SvgWriter()
|
||||||
|
|
||||||
drawing_style = context.scene.DocProperties.drawing_styles[
|
drawing_style = context.scene.DocProperties.drawing_styles[
|
||||||
camera.data.BIMCameraProperties.active_drawing_style_index
|
self.cprops.active_drawing_style_index
|
||||||
]
|
]
|
||||||
|
|
||||||
render = context.scene.render
|
render = context.scene.render
|
||||||
|
|||||||
@@ -153,6 +153,30 @@ def update_drawing_name(self, context):
|
|||||||
core.update_drawing_name(tool.Ifc, tool.Drawing, drawing=drawing, name=self.name)
|
core.update_drawing_name(tool.Ifc, tool.Drawing, drawing=drawing, name=self.name)
|
||||||
|
|
||||||
|
|
||||||
|
def update_has_underlay(self, context):
|
||||||
|
update_layer(self, context, "HasUnderlay", self.has_underlay)
|
||||||
|
|
||||||
|
|
||||||
|
def update_has_linework(self, context):
|
||||||
|
update_layer(self, context, "HasLinework", self.has_linework)
|
||||||
|
|
||||||
|
|
||||||
|
def update_has_annotation(self, context):
|
||||||
|
update_layer(self, context, "HasAnnotation", self.has_annotation)
|
||||||
|
|
||||||
|
|
||||||
|
def update_layer(self, context, name, value):
|
||||||
|
element = tool.Ifc.get_entity(context.active_object)
|
||||||
|
if not element:
|
||||||
|
return
|
||||||
|
pset = ifcopenshell.util.element.get_psets(element).get("EPset_Drawing")
|
||||||
|
if pset:
|
||||||
|
pset = tool.Ifc.get().by_id(pset["id"])
|
||||||
|
else:
|
||||||
|
pset = ifcopenshell.api.run("pset.add_pset", tool.Ifc.get(), product=element, name="EPset_Drawing")
|
||||||
|
ifcopenshell.api.run("pset.edit_pset", tool.Ifc.get(), pset=pset, properties={name: value})
|
||||||
|
|
||||||
|
|
||||||
def getTitleblocks(self, context):
|
def getTitleblocks(self, context):
|
||||||
global titleblocks_enum
|
global titleblocks_enum
|
||||||
if len(titleblocks_enum) < 1:
|
if len(titleblocks_enum) < 1:
|
||||||
@@ -276,9 +300,6 @@ class RasterStyleProperty(enum.Enum):
|
|||||||
|
|
||||||
|
|
||||||
class DocProperties(PropertyGroup):
|
class DocProperties(PropertyGroup):
|
||||||
has_underlay: BoolProperty(name="Underlay", default=False)
|
|
||||||
has_linework: BoolProperty(name="Linework", default=True)
|
|
||||||
has_annotation: BoolProperty(name="Annotation", default=True)
|
|
||||||
should_use_underlay_cache: BoolProperty(name="Use Underlay Cache", default=False)
|
should_use_underlay_cache: BoolProperty(name="Use Underlay Cache", default=False)
|
||||||
should_use_linework_cache: BoolProperty(name="Use Linework Cache", default=False)
|
should_use_linework_cache: BoolProperty(name="Use Linework Cache", default=False)
|
||||||
should_use_annotation_cache: BoolProperty(name="Use Annotation Cache", default=False)
|
should_use_annotation_cache: BoolProperty(name="Use Annotation Cache", default=False)
|
||||||
@@ -320,6 +341,9 @@ class DocProperties(PropertyGroup):
|
|||||||
|
|
||||||
|
|
||||||
class BIMCameraProperties(PropertyGroup):
|
class BIMCameraProperties(PropertyGroup):
|
||||||
|
has_underlay: BoolProperty(name="Underlay", default=False, update=update_has_underlay)
|
||||||
|
has_linework: BoolProperty(name="Linework", default=True, update=update_has_linework)
|
||||||
|
has_annotation: BoolProperty(name="Annotation", default=True, update=update_has_annotation)
|
||||||
representation: StringProperty(name="Representation")
|
representation: StringProperty(name="Representation")
|
||||||
view_name: StringProperty(name="View Name")
|
view_name: StringProperty(name="View Name")
|
||||||
diagram_scale: EnumProperty(items=get_diagram_scales, name="Drawing Scale", update=update_diagram_scale)
|
diagram_scale: EnumProperty(items=get_diagram_scales, name="Drawing Scale", update=update_diagram_scale)
|
||||||
|
|||||||
@@ -47,13 +47,13 @@ class BIM_PT_camera(Panel):
|
|||||||
|
|
||||||
col = layout.column(align=True)
|
col = layout.column(align=True)
|
||||||
row = col.row(align=True)
|
row = col.row(align=True)
|
||||||
row.prop(dprops, "has_underlay", icon="OUTLINER_OB_IMAGE")
|
row.prop(props, "has_underlay", icon="OUTLINER_OB_IMAGE")
|
||||||
row.prop(dprops, "should_use_underlay_cache", text="", icon="FILE_REFRESH")
|
row.prop(dprops, "should_use_underlay_cache", text="", icon="FILE_REFRESH")
|
||||||
row = col.row(align=True)
|
row = col.row(align=True)
|
||||||
row.prop(dprops, "has_linework", icon="IMAGE_DATA")
|
row.prop(props, "has_linework", icon="IMAGE_DATA")
|
||||||
row.prop(dprops, "should_use_linework_cache", text="", icon="FILE_REFRESH")
|
row.prop(dprops, "should_use_linework_cache", text="", icon="FILE_REFRESH")
|
||||||
row = col.row(align=True)
|
row = col.row(align=True)
|
||||||
row.prop(dprops, "has_annotation", icon="MOD_EDGESPLIT")
|
row.prop(props, "has_annotation", icon="MOD_EDGESPLIT")
|
||||||
row.prop(dprops, "should_use_annotation_cache", text="", icon="FILE_REFRESH")
|
row.prop(dprops, "should_use_annotation_cache", text="", icon="FILE_REFRESH")
|
||||||
|
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
|
|||||||
Reference in New Issue
Block a user