mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-20 23:36:20 +00:00
You can now add arbitrary annotation to a drawing, not just belonging to one of the preset types
This commit is contained in:
@@ -2152,7 +2152,16 @@ class CutSection(bpy.types.Operator):
|
|||||||
ifc_cutter.section_level_obj = None
|
ifc_cutter.section_level_obj = None
|
||||||
ifc_cutter.grid_objs = []
|
ifc_cutter.grid_objs = []
|
||||||
ifc_cutter.text_objs = []
|
ifc_cutter.text_objs = []
|
||||||
|
ifc_cutter.misc_objs = []
|
||||||
for obj in camera.users_collection[0].objects:
|
for obj in camera.users_collection[0].objects:
|
||||||
|
if 'IfcGrid' in obj.name:
|
||||||
|
ifc_cutter.grid_objs.append(obj)
|
||||||
|
elif 'IfcGroup' in obj.name and obj.type == 'CAMERA':
|
||||||
|
ifc_cutter.camera_obj = obj
|
||||||
|
|
||||||
|
if 'IfcAnnotation/' not in obj.name:
|
||||||
|
continue
|
||||||
|
|
||||||
if 'Leader' in obj.name:
|
if 'Leader' in obj.name:
|
||||||
ifc_cutter.leader_obj = (obj, obj.data)
|
ifc_cutter.leader_obj = (obj, obj.data)
|
||||||
elif 'Stair' in obj.name:
|
elif 'Stair' in obj.name:
|
||||||
@@ -2167,16 +2176,14 @@ class CutSection(bpy.types.Operator):
|
|||||||
ifc_cutter.hidden_objs.append((obj, obj.data))
|
ifc_cutter.hidden_objs.append((obj, obj.data))
|
||||||
elif 'Solid' in obj.name:
|
elif 'Solid' in obj.name:
|
||||||
ifc_cutter.solid_objs.append((obj, obj.data))
|
ifc_cutter.solid_objs.append((obj, obj.data))
|
||||||
elif 'IfcGrid' in obj.name:
|
|
||||||
ifc_cutter.grid_objs.append(obj)
|
|
||||||
elif 'Plan Level' in obj.name:
|
elif 'Plan Level' in obj.name:
|
||||||
ifc_cutter.plan_level_obj = obj
|
ifc_cutter.plan_level_obj = obj
|
||||||
elif 'Section Level' in obj.name:
|
elif 'Section Level' in obj.name:
|
||||||
ifc_cutter.section_level_obj = obj
|
ifc_cutter.section_level_obj = obj
|
||||||
elif obj.type == 'CAMERA':
|
|
||||||
ifc_cutter.camera_obj = obj
|
|
||||||
elif obj.type == 'FONT':
|
elif obj.type == 'FONT':
|
||||||
ifc_cutter.text_objs.append(obj)
|
ifc_cutter.text_objs.append(obj)
|
||||||
|
else:
|
||||||
|
ifc_cutter.misc_objs.append(obj)
|
||||||
|
|
||||||
ifc_cutter.section_box = {
|
ifc_cutter.section_box = {
|
||||||
'projection': tuple(projection),
|
'projection': tuple(projection),
|
||||||
|
|||||||
@@ -159,6 +159,9 @@ class SvgWriter():
|
|||||||
|
|
||||||
self.draw_ifc_annotation()
|
self.draw_ifc_annotation()
|
||||||
|
|
||||||
|
for obj in self.ifc_cutter.misc_objs:
|
||||||
|
self.draw_misc_annotation(obj, ['IfcAnnotation'])
|
||||||
|
|
||||||
for obj_data in self.ifc_cutter.hidden_objs:
|
for obj_data in self.ifc_cutter.hidden_objs:
|
||||||
self.draw_line_annotation(obj_data, ['hidden'])
|
self.draw_line_annotation(obj_data, ['hidden'])
|
||||||
|
|
||||||
@@ -264,6 +267,25 @@ class SvgWriter():
|
|||||||
line = self.svg.add(self.svg.line(start=tuple(start * self.scale),
|
line = self.svg.add(self.svg.line(start=tuple(start * self.scale),
|
||||||
end=tuple(end * self.scale), class_=' '.join(annotation['classes'])))
|
end=tuple(end * self.scale), class_=' '.join(annotation['classes'])))
|
||||||
|
|
||||||
|
def draw_misc_annotation(self, obj, classes):
|
||||||
|
# We have to decide whether this should come from Blender or from IFC.
|
||||||
|
# For the moment, for convenience of experimenting with ideas, it comes
|
||||||
|
# from Blender. In the future, it should probably come from IFC.
|
||||||
|
classes.extend(self.get_attribute_classes(obj))
|
||||||
|
if len(obj.data.polygons) == 0:
|
||||||
|
self.draw_edge_annotation(obj, classes)
|
||||||
|
return
|
||||||
|
x_offset = self.raw_width / 2
|
||||||
|
y_offset = self.raw_height / 2
|
||||||
|
matrix_world = obj.matrix_world
|
||||||
|
for polygon in obj.data.polygons:
|
||||||
|
points = [obj.data.vertices[v] for v in polygon.vertices]
|
||||||
|
projected_points = [self.project_point_onto_camera(matrix_world @ p.co.xyz) for p in points]
|
||||||
|
d = ' '.join(['L {} {}'.format(
|
||||||
|
(x_offset + p.x) * self.scale, (y_offset - p.y) * self.scale)
|
||||||
|
for p in projected_points])
|
||||||
|
d = 'M{}'.format(d[1:])
|
||||||
|
path = self.svg.add(self.svg.path(d=d, class_=' '.join(classes)))
|
||||||
def draw_line_annotation(self, obj_data, classes):
|
def draw_line_annotation(self, obj_data, classes):
|
||||||
# TODO: properly scope these offsets
|
# TODO: properly scope these offsets
|
||||||
x_offset = self.raw_width / 2
|
x_offset = self.raw_width / 2
|
||||||
|
|||||||
Reference in New Issue
Block a user