Minor fix

This commit is contained in:
Dion Moult
2023-03-20 17:03:39 +11:00
parent c97e1079e8
commit 72b5cc8a44
4 changed files with 18 additions and 9 deletions
@@ -65,8 +65,7 @@ class TextData:
element = tool.Ifc.get_entity(bpy.context.active_object)
if not element or not element.is_a("IfcAnnotation") or element.ObjectType not in ["TEXT", "TEXT_LEADER"]:
return []
rep = ifcopenshell.util.representation.get_representation(element, "Plan", "Annotation")
text_literal = [i for i in rep.Items if i.is_a("IfcTextLiteral")][0]
text_literal = tool.Drawing.get_text_literal(bpy.context.active_object)
return [
{"name": "Literal", "value": text_literal.Literal},
{"name": "BoxAlignment", "value": text_literal.BoxAlignment},
@@ -616,8 +616,7 @@ class SvgWriter:
x_offset = self.raw_width / 2
y_offset = self.raw_height / 2
element = tool.Ifc.get_entity(text_obj)
rep = ifcopenshell.util.representation.get_representation(element, "Plan", "Annotation")
text_literal = [i for i in rep.Items if i.is_a("IfcTextLiteral")][0]
text_literal = tool.Drawing.get_text_literal(text_obj)
text_position = self.project_point_onto_camera(position)
text_position = Vector(((x_offset + text_position.x), (y_offset - text_position.y)))
+3 -1
View File
@@ -304,7 +304,9 @@ class Drawing(blenderbim.core.tool.Drawing):
element = tool.Ifc.get_entity(obj)
if not element:
return
rep = ifcopenshell.util.representation.get_representation(element, "Plan", "Annotation")
rep = ifcopenshell.util.representation.get_representation(
element, "Plan", "Annotation"
) or ifcopenshell.util.representation.get_representation(element, "Model", "Annotation")
if not rep:
return
items = [i for i in rep.Items if i.is_a("IfcTextLiteral")]
@@ -114,7 +114,16 @@ class Usecase:
def create_model_representation(self):
if self.settings["context"].is_a() == "IfcGeometricRepresentationContext":
return self.create_variable_representation()
if self.settings["context"].ContextIdentifier == "Annotation":
elif self.settings["ifc_representation_class"] == "IfcTextLiteral":
return self.create_text_representation(is_2d=False)
elif self.settings["ifc_representation_class"] == "IfcGeometricCurveSet/IfcTextLiteral":
shape_representation = self.create_geometric_curve_set_representation(is_2d=True)
shape_representation.RepresentationType = "Annotation3D"
items = list(shape_representation.Items)
items.append(self.create_text())
shape_representation.Items = items
return shape_representation
elif self.settings["context"].ContextIdentifier == "Annotation":
return self.create_annotation3d_representation()
elif self.settings["context"].ContextIdentifier == "Axis":
return self.create_curve3d_representation()
@@ -140,7 +149,7 @@ class Usecase:
def create_plan_representation(self):
if self.settings["ifc_representation_class"] == "IfcTextLiteral":
return self.create_text_representation()
return self.create_text_representation(is_2d=True)
elif self.settings["ifc_representation_class"] == "IfcGeometricCurveSet/IfcTextLiteral":
shape_representation = self.create_geometric_curve_set_representation(is_2d=True)
shape_representation.RepresentationType = "Annotation2D"
@@ -194,11 +203,11 @@ class Usecase:
},
)
def create_text_representation(self):
def create_text_representation(self, is_2d=False):
return self.file.createIfcShapeRepresentation(
self.settings["context"],
self.settings["context"].ContextIdentifier,
"Annotation2D",
"Annotation2D" if is_2d else "Annotation3D",
[self.create_text()],
)