mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 22:50:21 +00:00
Using EPset_Drawing data instead of camera props on drawing print #3396
Previously if you change `HasUnderlay` in pset it caused errors because camera properties `has_underlay` wasn't updated. Still some work need to be done for updating keep camera properties in sync with pset - probably we can should call something like `tool.Drawing.import_drawing()` on EPset_Drawing edit
This commit is contained in:
@@ -32,6 +32,7 @@ import ifcopenshell
|
|||||||
import ifcopenshell.geom
|
import ifcopenshell.geom
|
||||||
import ifcopenshell.util.selector
|
import ifcopenshell.util.selector
|
||||||
import ifcopenshell.util.representation
|
import ifcopenshell.util.representation
|
||||||
|
import ifcopenshell.util.element
|
||||||
import blenderbim.bim.schema
|
import blenderbim.bim.schema
|
||||||
import blenderbim.tool as tool
|
import blenderbim.tool as tool
|
||||||
import blenderbim.core.drawing as core
|
import blenderbim.core.drawing as core
|
||||||
@@ -230,7 +231,8 @@ class CreateDrawing(bpy.types.Operator):
|
|||||||
with profile("Drawing generation process"):
|
with profile("Drawing generation process"):
|
||||||
with profile("Initialize drawing generation process"):
|
with profile("Initialize drawing generation process"):
|
||||||
self.cprops = self.camera.data.BIMCameraProperties
|
self.cprops = self.camera.data.BIMCameraProperties
|
||||||
self.drawing_name = self.file.by_id(drawing_id).Name
|
self.drawing = self.file.by_id(drawing_id)
|
||||||
|
self.drawing_name = self.drawing.Name
|
||||||
self.metadata = tool.Drawing.get_drawing_metadata(self.camera_element)
|
self.metadata = tool.Drawing.get_drawing_metadata(self.camera_element)
|
||||||
self.get_scale(context)
|
self.get_scale(context)
|
||||||
if self.cprops.update_representation(self.camera):
|
if self.cprops.update_representation(self.camera):
|
||||||
@@ -321,7 +323,7 @@ class CreateDrawing(bpy.types.Operator):
|
|||||||
return svg_path
|
return svg_path
|
||||||
|
|
||||||
def generate_underlay(self, context):
|
def generate_underlay(self, context):
|
||||||
if not self.cprops.has_underlay:
|
if not ifcopenshell.util.element.get_pset(self.drawing, "EPset_Drawing", "HasUnderlay"):
|
||||||
return
|
return
|
||||||
svg_path = self.get_svg_path(cache_type="underlay")
|
svg_path = self.get_svg_path(cache_type="underlay")
|
||||||
context.scene.render.filepath = svg_path[0:-4] + ".png"
|
context.scene.render.filepath = svg_path[0:-4] + ".png"
|
||||||
@@ -363,7 +365,8 @@ class CreateDrawing(bpy.types.Operator):
|
|||||||
return svg_path
|
return svg_path
|
||||||
|
|
||||||
def generate_linework(self, context):
|
def generate_linework(self, context):
|
||||||
if not self.cprops.has_linework:
|
global ifcopenshell
|
||||||
|
if not ifcopenshell.util.element.get_pset(self.drawing, "EPset_Drawing", "HasLinework"):
|
||||||
return
|
return
|
||||||
svg_path = self.get_svg_path(cache_type="linework")
|
svg_path = self.get_svg_path(cache_type="linework")
|
||||||
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:
|
||||||
@@ -968,7 +971,7 @@ class CreateDrawing(bpy.types.Operator):
|
|||||||
group.insert(0, projection)
|
group.insert(0, projection)
|
||||||
|
|
||||||
def generate_annotation(self, context):
|
def generate_annotation(self, context):
|
||||||
if not self.cprops.has_annotation:
|
if not ifcopenshell.util.element.get_pset(self.drawing, "EPset_Drawing", "HasAnnotation"):
|
||||||
return
|
return
|
||||||
svg_path = self.get_svg_path(cache_type="annotation")
|
svg_path = self.get_svg_path(cache_type="annotation")
|
||||||
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:
|
||||||
@@ -1704,7 +1707,7 @@ class ActivateDrawingStyle(bpy.types.Operator, Operator):
|
|||||||
exec(f"{path} = {value}")
|
exec(f"{path} = {value}")
|
||||||
except:
|
except:
|
||||||
# Differences in Blender versions mean result in failures here
|
# Differences in Blender versions mean result in failures here
|
||||||
print("Failed to set shading style {path} to {value}")
|
print(f"Failed to set shading style {path} to {value}")
|
||||||
|
|
||||||
def set_query(self, context):
|
def set_query(self, context):
|
||||||
self.include_global_ids = []
|
self.include_global_ids = []
|
||||||
|
|||||||
@@ -547,6 +547,9 @@ class Drawing(blenderbim.core.tool.Drawing):
|
|||||||
for obj in ifc_importer.added_data.values():
|
for obj in ifc_importer.added_data.values():
|
||||||
tool.Collector.assign(obj)
|
tool.Collector.assign(obj)
|
||||||
|
|
||||||
|
# NOTE: EPsetDrawing pset is completely synced with BIMCameraProperties
|
||||||
|
# but BIMCameraProperties are only synced with EPsetDrawing at drawing import
|
||||||
|
# therefore camera props can differ from pset if the user changed them from pset.
|
||||||
@classmethod
|
@classmethod
|
||||||
def import_drawing(cls, drawing):
|
def import_drawing(cls, drawing):
|
||||||
settings = ifcopenshell.geom.settings()
|
settings = ifcopenshell.geom.settings()
|
||||||
|
|||||||
Reference in New Issue
Block a user