mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-12 22:43:41 +00:00
- Now with actual logging to Blender texts
- More detailed feedback on progress and pop-up when import fails
This commit is contained in:
@@ -61,8 +61,10 @@ bpy.types.Object.ifc_type = StringProperty(name="IFC Entity Type",
|
|||||||
|
|
||||||
def import_ifc(filename, use_names, process_relations):
|
def import_ifc(filename, use_names, process_relations):
|
||||||
from . import IfcImport
|
from . import IfcImport
|
||||||
|
print("Reading %s..."%bpy.path.basename(filename))
|
||||||
if not IfcImport.Init(filename):
|
if not IfcImport.Init(filename):
|
||||||
return
|
return False
|
||||||
|
print("Done reading file")
|
||||||
id_to_object = {}
|
id_to_object = {}
|
||||||
id_to_parent = {}
|
id_to_parent = {}
|
||||||
id_to_matrix = {}
|
id_to_matrix = {}
|
||||||
@@ -126,6 +128,9 @@ def import_ifc(filename, use_names, process_relations):
|
|||||||
print("\rDone creating geometry" + " " * 30)
|
print("\rDone creating geometry" + " " * 30)
|
||||||
|
|
||||||
id_to_parent_temp = dict(id_to_parent)
|
id_to_parent_temp = dict(id_to_parent)
|
||||||
|
|
||||||
|
if process_relations:
|
||||||
|
print("Processing relations...")
|
||||||
|
|
||||||
while len(id_to_parent_temp) and process_relations:
|
while len(id_to_parent_temp) and process_relations:
|
||||||
id, parent_id = id_to_parent_temp.popitem()
|
id, parent_id = id_to_parent_temp.popitem()
|
||||||
@@ -171,8 +176,16 @@ def import_ifc(filename, use_names, process_relations):
|
|||||||
id_to_object[id].matrix_local = parent_matrix.inverted() * matrix
|
id_to_object[id].matrix_local = parent_matrix.inverted() * matrix
|
||||||
else:
|
else:
|
||||||
id_to_object[id].matrix_world = matrix
|
id_to_object[id].matrix_world = matrix
|
||||||
|
|
||||||
|
if process_relations:
|
||||||
|
print("Done processing relations")
|
||||||
|
|
||||||
|
txt = bpy.data.texts.new("%s.log"%bpy.path.basename(filename))
|
||||||
|
txt.from_string(IfcImport.GetLog())
|
||||||
|
|
||||||
IfcImport.CleanUp()
|
IfcImport.CleanUp()
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
class ImportIFC(bpy.types.Operator, ImportHelper):
|
class ImportIFC(bpy.types.Operator, ImportHelper):
|
||||||
@@ -191,7 +204,10 @@ class ImportIFC(bpy.types.Operator, ImportHelper):
|
|||||||
default=True)
|
default=True)
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
import_ifc(self.filepath, self.use_names, self.process_relations)
|
if not import_ifc(self.filepath, self.use_names, self.process_relations):
|
||||||
|
self.report('ERROR',
|
||||||
|
'Unable to parse .ifc file or no geometrical entities found'
|
||||||
|
)
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user