mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-17 14:02:27 +00:00
Fix #3420. Fix missing sheet references on drawings and incorrect direction of section references.
This commit is contained in:
@@ -717,15 +717,19 @@ class SvgWriter:
|
|||||||
drawing = tool.Drawing.get_annotation_element(element)
|
drawing = tool.Drawing.get_annotation_element(element)
|
||||||
reference = tool.Drawing.get_drawing_reference(drawing)
|
reference = tool.Drawing.get_drawing_reference(drawing)
|
||||||
if reference:
|
if reference:
|
||||||
sheet = tool.Drawing.get_reference_document(reference)
|
for sheet_reference in tool.Ifc.get().by_type("IfcDocumentReference"):
|
||||||
if sheet:
|
if sheet_reference.Description != "DRAWING" or sheet_reference.Location != reference.Location:
|
||||||
if tool.Ifc.get_schema() == "IFC2X3":
|
continue
|
||||||
reference_id = reference.ItemReference or "-"
|
sheet = tool.Drawing.get_reference_document(sheet_reference)
|
||||||
sheet_id = sheet.DocumentId or "-"
|
if sheet:
|
||||||
else:
|
if tool.Ifc.get_schema() == "IFC2X3":
|
||||||
reference_id = reference.Identification or "-"
|
reference_id = sheet_reference.ItemReference or "-"
|
||||||
sheet_id = sheet.Identification or "-"
|
sheet_id = sheet.DocumentId or "-"
|
||||||
return (reference_id, sheet_id)
|
else:
|
||||||
|
reference_id = sheet_reference.Identification or "-"
|
||||||
|
sheet_id = sheet.Identification or "-"
|
||||||
|
return (reference_id, sheet_id)
|
||||||
|
break
|
||||||
return ("-", "-")
|
return ("-", "-")
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
@@ -370,7 +370,7 @@ def build_schedule(drawing, schedule=None):
|
|||||||
|
|
||||||
|
|
||||||
def sync_references(ifc, collector, drawing_tool, drawing=None):
|
def sync_references(ifc, collector, drawing_tool, drawing=None):
|
||||||
if not drawing_tool.has_linework(drawing):
|
if not drawing_tool.has_annotation(drawing):
|
||||||
return
|
return
|
||||||
|
|
||||||
context = drawing_tool.get_annotation_context(drawing_tool.get_drawing_target_view(drawing))
|
context = drawing_tool.get_annotation_context(drawing_tool.get_drawing_target_view(drawing))
|
||||||
|
|||||||
@@ -1057,20 +1057,28 @@ class Drawing(blenderbim.core.tool.Drawing):
|
|||||||
reference_mesh = cls.get_camera_block(reference_obj)
|
reference_mesh = cls.get_camera_block(reference_obj)
|
||||||
obj_matrix = to_camera_coords(camera, reference_obj)
|
obj_matrix = to_camera_coords(camera, reference_obj)
|
||||||
|
|
||||||
# The reference mesh vertices represent a view cube. To convert this into a section line we:
|
# The reference mesh vertices represent a view cube. To convert
|
||||||
# 1. Select the 4 +Z vertices local to the reference element. This is the cutting plane.
|
# this into a section line we:
|
||||||
|
# 1. Select the 4 +Z vertices local to the reference element. This
|
||||||
|
# is the cutting plane.
|
||||||
verts_local_to_reference = [reference_obj.matrix_world.inverted() @ v for v in reference_mesh["verts"]]
|
verts_local_to_reference = [reference_obj.matrix_world.inverted() @ v for v in reference_mesh["verts"]]
|
||||||
cutting_plane_verts = sorted(verts_local_to_reference, key=lambda x: x.z)[-4:]
|
cutting_plane_verts = sorted(verts_local_to_reference, key=lambda x: x.z)[-4:]
|
||||||
global_cutting_plane_verts = [reference_obj.matrix_world @ v for v in cutting_plane_verts]
|
global_cutting_plane_verts = [reference_obj.matrix_world @ v for v in cutting_plane_verts]
|
||||||
# 2. Project the cutting plane onto our viewing camera.
|
# 2. Project the cutting plane onto our viewing camera.
|
||||||
verts_local_to_camera = [camera.matrix_world.inverted() @ v for v in global_cutting_plane_verts]
|
verts_local_to_camera = [camera.matrix_world.inverted() @ v for v in global_cutting_plane_verts]
|
||||||
# 3. Collapse verts with the same XY coords, and set Z to be just below the clip_start so it's visible
|
# 3. Collapse verts with the same XY coords, and set Z to be just
|
||||||
|
# below the clip_start so it's visible
|
||||||
collapsed_verts = []
|
collapsed_verts = []
|
||||||
for vert in verts_local_to_camera:
|
for vert in verts_local_to_camera:
|
||||||
if not [True for v in collapsed_verts if (vert.xy - v.xy).length < 1e-2]:
|
if not [True for v in collapsed_verts if (vert.xy - v.xy).length < 1e-2]:
|
||||||
collapsed_verts.append(mathutils.Vector((vert.x, vert.y, -camera.data.clip_start - 0.05)))
|
collapsed_verts.append(mathutils.Vector((vert.x, vert.y, -camera.data.clip_start - 0.05)))
|
||||||
# 4. The first two vertices is the section line
|
# 4. The first two vertices is the section line
|
||||||
section_line = collapsed_verts[0:2]
|
section_line = collapsed_verts[0:2]
|
||||||
|
# 5. Sort the vertices in the +X direction so that the vertices are
|
||||||
|
# ordered to "point" in the direction of the section cut.
|
||||||
|
section_line = sorted(
|
||||||
|
section_line, key=lambda co: (reference_obj.matrix_world.inverted() @ camera.matrix_world @ co).x
|
||||||
|
)
|
||||||
global_section_line = [camera.matrix_world @ v for v in section_line]
|
global_section_line = [camera.matrix_world @ v for v in section_line]
|
||||||
local_section_line = [obj_matrix.inverted() @ v for v in global_section_line]
|
local_section_line = [obj_matrix.inverted() @ v for v in global_section_line]
|
||||||
|
|
||||||
@@ -1377,6 +1385,10 @@ class Drawing(blenderbim.core.tool.Drawing):
|
|||||||
def has_linework(cls, drawing):
|
def has_linework(cls, drawing):
|
||||||
return ifcopenshell.util.element.get_psets(drawing).get("EPset_Drawing", {}).get("HasLinework", False)
|
return ifcopenshell.util.element.get_psets(drawing).get("EPset_Drawing", {}).get("HasLinework", False)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def has_annotation(cls, drawing):
|
||||||
|
return ifcopenshell.util.element.get_psets(drawing).get("EPset_Drawing", {}).get("HasAnnotation", False)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def get_drawing_elements(cls, drawing):
|
def get_drawing_elements(cls, drawing):
|
||||||
"""returns a set of elements that are included in the drawing"""
|
"""returns a set of elements that are included in the drawing"""
|
||||||
@@ -1489,7 +1501,9 @@ class Drawing(blenderbim.core.tool.Drawing):
|
|||||||
project_collection.children["Views"].children[collection.name].hide_viewport = True
|
project_collection.children["Views"].children[collection.name].hide_viewport = True
|
||||||
bpy.data.collections.get(collection.name).hide_render = True
|
bpy.data.collections.get(collection.name).hide_render = True
|
||||||
|
|
||||||
project_collection.children["Views"].children[camera.BIMObjectProperties.collection.name].hide_viewport = False
|
project_collection.children["Views"].children[
|
||||||
|
camera.BIMObjectProperties.collection.name
|
||||||
|
].hide_viewport = False
|
||||||
camera.BIMObjectProperties.collection.hide_render = False
|
camera.BIMObjectProperties.collection.hide_render = False
|
||||||
tool.Spatial.set_active_object(camera)
|
tool.Spatial.set_active_object(camera)
|
||||||
|
|
||||||
|
|||||||
@@ -242,6 +242,10 @@ Create a simple model from scratch
|
|||||||
|
|
||||||
# Let's create a new wall
|
# Let's create a new wall
|
||||||
wall = run("root.create_entity", model, ifc_class="IfcWall")
|
wall = run("root.create_entity", model, ifc_class="IfcWall")
|
||||||
|
|
||||||
|
# Give our wall a local origin at (0, 0, 0)
|
||||||
|
run("geometry.edit_object_placement", model, product=wall)
|
||||||
|
|
||||||
# Add a new wall-like body geometry, 5 meters long, 3 meters high, and 200mm thick
|
# Add a new wall-like body geometry, 5 meters long, 3 meters high, and 200mm thick
|
||||||
representation = run("geometry.add_wall_representation", model, context=body, length=5, height=3, thickness=0.2)
|
representation = run("geometry.add_wall_representation", model, context=body, length=5, height=3, thickness=0.2)
|
||||||
# Assign our new body geometry back to our wall
|
# Assign our new body geometry back to our wall
|
||||||
|
|||||||
Reference in New Issue
Block a user