mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-26 02:07:36 +00:00
Fix #1558. New loading bar when importing an IFC.
This commit is contained in:
@@ -159,8 +159,16 @@ class IfcImporter:
|
|||||||
self.time = time.time()
|
self.time = time.time()
|
||||||
print("{} :: {:.2f}".format(message, time.time() - self.time))
|
print("{} :: {:.2f}".format(message, time.time() - self.time))
|
||||||
self.time = time.time()
|
self.time = time.time()
|
||||||
|
self.update_progress(self.progress + 1)
|
||||||
|
|
||||||
|
def update_progress(self, progress):
|
||||||
|
if progress <= 100:
|
||||||
|
self.progress = progress
|
||||||
|
bpy.context.window_manager.progress_update(self.progress)
|
||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
|
bpy.context.window_manager.progress_begin(0, 100)
|
||||||
|
self.progress = 0
|
||||||
self.profile_code("Starting import process")
|
self.profile_code("Starting import process")
|
||||||
self.load_diff()
|
self.load_diff()
|
||||||
self.profile_code("Load diff")
|
self.profile_code("Load diff")
|
||||||
@@ -228,6 +236,8 @@ class IfcImporter:
|
|||||||
self.profile_code("Mesh cleaning")
|
self.profile_code("Mesh cleaning")
|
||||||
self.set_default_context()
|
self.set_default_context()
|
||||||
self.profile_code("Setting default context")
|
self.profile_code("Setting default context")
|
||||||
|
self.update_progress(100)
|
||||||
|
bpy.context.window_manager.progress_end()
|
||||||
|
|
||||||
def is_element_far_away(self, element, is_meters=True):
|
def is_element_far_away(self, element, is_meters=True):
|
||||||
try:
|
try:
|
||||||
@@ -546,12 +556,21 @@ class IfcImporter:
|
|||||||
if not valid_file:
|
if not valid_file:
|
||||||
return False
|
return False
|
||||||
checkpoint = time.time()
|
checkpoint = time.time()
|
||||||
total = 0
|
total_created = 0
|
||||||
|
approx_total_products = len(self.include_elements) or len(self.file.by_type("IfcElement"))
|
||||||
|
start_progress = self.progress
|
||||||
|
progress_range = 85 - start_progress
|
||||||
while True:
|
while True:
|
||||||
total += 1
|
if total_created % 250 == 0:
|
||||||
if total % 250 == 0:
|
print(
|
||||||
print("{} elements processed in {:.2f}s ...".format(total, time.time() - checkpoint))
|
"{} / ~{} elements processed in {:.2f}s ...".format(
|
||||||
|
total_created, approx_total_products, time.time() - checkpoint
|
||||||
|
)
|
||||||
|
)
|
||||||
checkpoint = time.time()
|
checkpoint = time.time()
|
||||||
|
self.update_progress(
|
||||||
|
((total_created / approx_total_products) * progress_range) + start_progress
|
||||||
|
)
|
||||||
shape = iterator.get()
|
shape = iterator.get()
|
||||||
if shape:
|
if shape:
|
||||||
product = self.file.by_id(shape.guid)
|
product = self.file.by_id(shape.guid)
|
||||||
@@ -565,6 +584,7 @@ class IfcImporter:
|
|||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
self.create_product(product, shape)
|
self.create_product(product, shape)
|
||||||
|
total_created += 1
|
||||||
if not iterator.next():
|
if not iterator.next():
|
||||||
break
|
break
|
||||||
print("Done creating geometry")
|
print("Done creating geometry")
|
||||||
|
|||||||
Reference in New Issue
Block a user