diff --git a/src/ifcblender/IfcBlender.py b/src/ifcblender/io_import_scene_ifc/__init__.py similarity index 60% rename from src/ifcblender/IfcBlender.py rename to src/ifcblender/io_import_scene_ifc/__init__.py index 9239685c95..04bad62b5f 100644 --- a/src/ifcblender/IfcBlender.py +++ b/src/ifcblender/io_import_scene_ifc/__init__.py @@ -1,22 +1,29 @@ -############################################################################## -# # -#This file is part of IfcOpenShell. # -# # -#IfcOpenShell is free software: you can redistribute it and/or modify # -#it under the terms of the Lesser GNU General Public License as published by # -#the Free Software Foundation, either version 3.0 of the License, or # -#(at your option) any later version. # -# # -#IfcOpenShell is distributed in the hope that it will be useful, # -#but WITHOUT ANY WARRANTY; without even the implied warranty of # -#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # -#Lesser GNU General Public License for more details. # -# # -#You should have received a copy of the Lesser GNU General Public License # -#along with this program. If not, see . # -# # -############################################################################## +############################################################################### +# # +# This file is part of IfcOpenShell. # +# # +# IfcOpenShell is free software: you can redistribute it and/or modify # +# it under the terms of the Lesser GNU General Public License as published by # +# the Free Software Foundation, either version 3.0 of the License, or # +# (at your option) any later version. # +# # +# IfcOpenShell is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# Lesser GNU General Public License for more details. # +# # +# You should have received a copy of the Lesser GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################### +# + +############################################################################### +# # +# Based on the Wavefront OBJ File importer by Campbell Barton # +# # +############################################################################### bl_info = { "name": "IfcBlender", @@ -32,12 +39,17 @@ bl_info = { "tracker_url": "http://sourceforge.net/tracker/?group_id=543113", "category": "Import-Export"} +if "bpy" in locals(): + import imp + if "IfcImport" in locals(): + imp.reload(IfcImport) import bpy import mathutils -from bpy.props import * +from bpy.props import StringProperty from bpy_extras.io_utils import ImportHelper + class ImportIFC(bpy.types.Operator, ImportHelper): bl_idname = "import_scene.ifc" bl_label = "Import .ifc file" @@ -46,7 +58,7 @@ class ImportIFC(bpy.types.Operator, ImportHelper): filter_glob = StringProperty(default="*.ifc", options={'HIDDEN'}) def execute(self, context): - import IfcImport + from . import IfcImport if not IfcImport.Init(self.filepath): return {'FINISHED'} ids = {} @@ -56,22 +68,19 @@ class ImportIFC(bpy.types.Operator, ImportHelper): f = ob.mesh.faces v = ob.mesh.verts m = ob.matrix + t = ob.type[0:21] if ob.mesh.id in ids: me = ids[ob.mesh.id] else: - verts = [] - faces = [] - for i in range(0, len(f), 3): - faces.append([f[i + 0], f[i + 1], f[i + 2]]) - for i in range(0, len(v), 3): - verts.append([v[i + 0], v[i + 1], v[i + 2]]) + verts = [[v[i],v[i+1],v[i+2]] for i in range(0,len(v),3)] + faces = [[f[i],f[i+1],f[i+2]] for i in range(0,len(f),3)] me = bpy.data.meshes.new('mesh%d' % ob.mesh.id) me.from_pydata(verts, [], faces) - if ob.type in bpy.data.materials: - mat = bpy.data.materials[ob.type] + if t in bpy.data.materials: + mat = bpy.data.materials[t] mat.use_fake_user = True else: - mat = bpy.data.materials.new(ob.type) + mat = bpy.data.materials.new(t) me.materials.append(mat) ids[ob.mesh.id] = me bob = bpy.data.objects.new(ob.name, me) @@ -80,7 +89,7 @@ class ImportIFC(bpy.types.Operator, ImportHelper): [m[6], m[7], m[8], 0], [m[9], m[10], m[11], 1])) bpy.context.scene.objects.link(bob) - me.update() + #me.update() bpy.ops.object.select_all(action='DESELECT') bpy.ops.object.select_name(name=bob.name) bpy.ops.object.mode_set(mode='EDIT')