mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 18:12:28 +00:00
Optimise rebar profile creation on IFC import
This commit is contained in:
@@ -197,6 +197,7 @@ class IfcImporter():
|
|||||||
self.time = 0
|
self.time = 0
|
||||||
self.unit_scale = 1
|
self.unit_scale = 1
|
||||||
self.added_data = {}
|
self.added_data = {}
|
||||||
|
self.native_elements = {}
|
||||||
self.native_data = {}
|
self.native_data = {}
|
||||||
self.groups = {}
|
self.groups = {}
|
||||||
|
|
||||||
@@ -268,16 +269,17 @@ class IfcImporter():
|
|||||||
|
|
||||||
def parse_native_products(self):
|
def parse_native_products(self):
|
||||||
# TODO: simple code for now as we only treat rebar specially
|
# TODO: simple code for now as we only treat rebar specially
|
||||||
|
self.native_data['rebar_profiles'] = {}
|
||||||
for element in self.file.by_type('IfcReinforcingBar'):
|
for element in self.file.by_type('IfcReinforcingBar'):
|
||||||
for representation in element.Representation.Representations:
|
for representation in element.Representation.Representations:
|
||||||
self.replace_with_directrix(representation, element)
|
self.replace_with_directrix(representation, element)
|
||||||
for item in representation.Items:
|
for item in representation.Items:
|
||||||
if item.is_a('IfcMappedItem'):
|
if item.is_a('IfcMappedItem'):
|
||||||
self.replace_with_directrix(item.MappingSource.MappedRepresentation, element)
|
self.replace_with_directrix(item.MappingSource.MappedRepresentation, element)
|
||||||
for global_id, data in self.native_data.items():
|
for radius in self.native_data['rebar_profiles'].keys():
|
||||||
bevel_object = bpy.data.objects.new('rebar-profile', self.create_bezier_circle(data['radius']))
|
obj = bpy.data.objects.new('rebar-profile-{}'.format(radius), self.create_bezier_circle(radius))
|
||||||
bpy.context.scene.collection.objects.link(bevel_object)
|
self.native_data['rebar_profiles'][radius] = obj
|
||||||
data['bevel_object'] = bevel_object
|
bpy.context.scene.collection.objects.link(obj)
|
||||||
|
|
||||||
def create_bezier_circle(self, radius):
|
def create_bezier_circle(self, radius):
|
||||||
curve = bpy.data.curves.new('circle-profile', type='CURVE')
|
curve = bpy.data.curves.new('circle-profile', type='CURVE')
|
||||||
@@ -307,7 +309,9 @@ class IfcImporter():
|
|||||||
for item in representation.Items:
|
for item in representation.Items:
|
||||||
if item.is_a('IfcSweptDiskSolid'):
|
if item.is_a('IfcSweptDiskSolid'):
|
||||||
new_items.append(item.Directrix)
|
new_items.append(item.Directrix)
|
||||||
self.native_data[element.GlobalId] = { 'radius': self.unit_scale * item.Radius }
|
radius = round(self.unit_scale * item.Radius, 3)
|
||||||
|
self.native_elements[element.GlobalId] = { 'radius': radius }
|
||||||
|
self.native_data['rebar_profiles'][radius] = None
|
||||||
else:
|
else:
|
||||||
new_items.append(item)
|
new_items.append(item)
|
||||||
representation.Items = new_items
|
representation.Items = new_items
|
||||||
@@ -461,7 +465,7 @@ class IfcImporter():
|
|||||||
# TODO: figure out a design pattern for native objects
|
# TODO: figure out a design pattern for native objects
|
||||||
if element.is_a('IfcReinforcingBar'):
|
if element.is_a('IfcReinforcingBar'):
|
||||||
mesh = self.create_mesh(element, shape, is_curve=True)
|
mesh = self.create_mesh(element, shape, is_curve=True)
|
||||||
mesh.bevel_object = self.native_data[element.GlobalId]['bevel_object']
|
mesh.bevel_object = self.native_data['rebar_profiles'][self.native_elements[element.GlobalId]['radius']]
|
||||||
mesh.use_fill_caps = True
|
mesh.use_fill_caps = True
|
||||||
else:
|
else:
|
||||||
mesh = self.create_mesh(element, shape)
|
mesh = self.create_mesh(element, shape)
|
||||||
|
|||||||
Reference in New Issue
Block a user