mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
Support IfcIndexedPolyCurve for more robust 2D representations
This commit is contained in:
@@ -2433,21 +2433,9 @@ class IfcExporter():
|
||||
return self.create_curves_from_curve(curve, is_2d=is_2d)
|
||||
|
||||
def create_curves_from_mesh(self, mesh, is_2d=False):
|
||||
self.create_vertices(mesh.vertices, is_2d=is_2d)
|
||||
edges = list(mesh.edges)
|
||||
loop_vertices = []
|
||||
loops = []
|
||||
# Not a fast algorithm, but easy
|
||||
while edges:
|
||||
for i, edge in enumerate(edges):
|
||||
if edge.vertices[0] in loop_vertices \
|
||||
and edge.vertices[1] in loop_vertices:
|
||||
del edges[i]
|
||||
loop_vertex_indices = self.get_loop_from_edges(edges)
|
||||
loop_vertices.extend(loop_vertex_indices)
|
||||
loops.append(self.file.createIfcPolyline([
|
||||
self.ifc_vertices[i] for i in loop_vertex_indices]))
|
||||
return loops
|
||||
return [self.file.createIfcIndexedPolyCurve(
|
||||
self.create_cartesian_point_list_from_vertices(mesh.vertices, is_2d=is_2d),
|
||||
[self.file.createIfcLineIndex(tuple(e.vertices)) for e in mesh.edges])]
|
||||
|
||||
def create_curves_from_curve(self, curve, is_2d=False):
|
||||
results = []
|
||||
@@ -2690,6 +2678,11 @@ class IfcExporter():
|
||||
representation['target_view']]['ifc'],
|
||||
representation['subcontext'], 'Brep', items)
|
||||
|
||||
def create_cartesian_point_list_from_vertices(self, vertices, is_2d=False):
|
||||
if is_2d:
|
||||
return self.file.createIfcCartesianPointList2D([self.convert_si_to_unit(v.co.xy) for v in vertices])
|
||||
return self.file.createIfcCartesianPointList3D([self.convert_si_to_unit(v.co) for v in vertices])
|
||||
|
||||
def create_vertices(self, vertices, is_2d=False):
|
||||
if is_2d:
|
||||
for v in vertices:
|
||||
|
||||
@@ -31,7 +31,7 @@ def add_object(self, context):
|
||||
]
|
||||
edges = [[0, 1], [1, 2], [2, 3]]
|
||||
faces = []
|
||||
mesh = bpy.data.meshes.new(name="IfcDoor/Dumb Door")
|
||||
mesh = bpy.data.meshes.new(name="Dumb Door")
|
||||
mesh.from_pydata(verts, edges, faces)
|
||||
obj2 = object_data_add(context, mesh, operator=self)
|
||||
bpy.ops.object.convert(target='CURVE')
|
||||
@@ -85,11 +85,13 @@ def add_object(self, context):
|
||||
obj4.display_type = 'WIRE'
|
||||
obj4.parent = obj2
|
||||
obj4.matrix_parent_inverse = obj2.matrix_world.inverted()
|
||||
obj4.hide_render = True
|
||||
obj4.name = 'IfcOpeningElement/Dumb Door Opening'
|
||||
attribute = obj4.BIMObjectProperties.attributes.add()
|
||||
attribute.name = 'PredefinedType'
|
||||
attribute.string_value = 'OPENING'
|
||||
|
||||
obj2.name = 'IfcDoor/Dumb Door'
|
||||
attribute = obj2.BIMObjectProperties.attributes.add()
|
||||
attribute.name = 'PredefinedType'
|
||||
attribute.string_value = 'DOOR'
|
||||
|
||||
@@ -29,7 +29,7 @@ def add_object(self, context):
|
||||
]
|
||||
edges = [[0, 1], [1, 2], [2, 3]]
|
||||
faces = []
|
||||
mesh = bpy.data.meshes.new(name="IfcWindow/Dumb Window")
|
||||
mesh = bpy.data.meshes.new(name="Dumb Window")
|
||||
mesh.from_pydata(verts, edges, faces)
|
||||
obj2 = object_data_add(context, mesh, operator=self)
|
||||
bpy.ops.object.convert(target='CURVE')
|
||||
@@ -84,11 +84,13 @@ def add_object(self, context):
|
||||
obj4.display_type = 'WIRE'
|
||||
obj4.parent = obj2
|
||||
obj4.matrix_parent_inverse = obj2.matrix_world.inverted()
|
||||
obj4.hide_render = True
|
||||
obj4.name = 'IfcOpeningElement/Dumb Window Opening'
|
||||
attribute = obj4.BIMObjectProperties.attributes.add()
|
||||
attribute.name = 'PredefinedType'
|
||||
attribute.string_value = 'OPENING'
|
||||
|
||||
obj2.name = 'IfcWindow/Dumb Window'
|
||||
attribute = obj2.BIMObjectProperties.attributes.add()
|
||||
attribute.name = 'PredefinedType'
|
||||
attribute.string_value = 'WINDOW'
|
||||
|
||||
@@ -2123,6 +2123,8 @@ class CutSection(bpy.types.Operator):
|
||||
elif obj.type == 'FONT':
|
||||
ifc_cutter.text_objs.append(obj)
|
||||
|
||||
# TODO: this should be detected from the IFC, not from Blender, and
|
||||
# should use a bbox calculation to determine whether it is shown
|
||||
for obj in bpy.context.visible_objects:
|
||||
for subcontext in obj.BIMObjectProperties.representation_contexts:
|
||||
if subcontext.context == 'Plan' \
|
||||
|
||||
Reference in New Issue
Block a user