mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-13 10:57:49 +00:00
Update PLAN_LEVEL annotation (#6844)
* Update PLAN_LEVEL annotation * Length of line segment based on scale --------- Co-authored-by: Ryan Schultz <ryan@openingdesign.com>
This commit is contained in:
@@ -157,6 +157,8 @@ class Drawing(bonsai.core.tool.Drawing):
|
||||
def create_annotation_object(cls, drawing: ifcopenshell.entity_instance, object_type: str) -> bpy.types.Object:
|
||||
import bonsai.bim.module.drawing.annotation as annotation
|
||||
|
||||
pset = ifcopenshell.util.element.get_pset(drawing, "EPset_Drawing")
|
||||
scale = 1 / float(Fraction(pset["Scale"]))
|
||||
data_type = cls.get_annotation_data_type(object_type)
|
||||
obj = annotation.Annotator.get_annotation_obj(drawing, object_type, data_type)
|
||||
if object_type == "FILL_AREA":
|
||||
@@ -168,6 +170,17 @@ class Drawing(bonsai.core.tool.Drawing):
|
||||
elif object_type == "TEXT_LEADER":
|
||||
co1, _, co2, _ = annotation.Annotator.get_placeholder_coords()
|
||||
obj = annotation.Annotator.add_line_to_annotation(obj, co2, co1)
|
||||
elif object_type == "PLAN_LEVEL":
|
||||
co1, co2, _, _ = annotation.Annotator.get_placeholder_coords()
|
||||
vec = co2 - co1
|
||||
if vec.length == 0:
|
||||
vec = Vector((1, 0, 0)) # Fallback to a unit vector
|
||||
else:
|
||||
vec = vec.normalized()
|
||||
scaled_length = 0.023 * scale #0.023 could probably be a preference
|
||||
co_end = co1 + vec * scaled_length
|
||||
obj = annotation.Annotator.add_line_to_annotation(obj, co_end, co1)
|
||||
obj.matrix_world = obj.matrix_world @ Matrix.Rotation(math.radians(-90), 4, "Z")
|
||||
elif object_type != "TEXT":
|
||||
obj = annotation.Annotator.add_line_to_annotation(obj)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user