mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 22:33:33 +00:00
Update fetch object passport to substitute a mesh from a Blender file only. See #871.
This commit is contained in:
@@ -1696,25 +1696,18 @@ class FetchObjectPassport(bpy.types.Operator):
|
|||||||
bl_label = 'Fetch Object Passport'
|
bl_label = 'Fetch Object Passport'
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
for document in bpy.context.active_object.BIMObjectProperties.documents:
|
for reference in bpy.context.active_object.BIMObjectProperties.document_references:
|
||||||
if not document.file[-6:] == '.opass':
|
reference = bpy.context.scene.BIMProperties.document_references[reference.name]
|
||||||
continue
|
if reference.location[-6:] == '.blend':
|
||||||
with open(os.path.join(bpy.context.scene.BIMProperties.data_dir, 'doc', document.file)) as f:
|
self.fetch_blender(reference)
|
||||||
self.object_pass = json.load(f)
|
|
||||||
if 'blender' in self.object_pass:
|
|
||||||
self.fetch_blender()
|
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
def fetch_blender(self):
|
def fetch_blender(self, reference):
|
||||||
identification = self.object_pass['blender']['identification']
|
|
||||||
uri = os.path.join(bpy.context.scene.BIMProperties.data_dir,
|
|
||||||
'doc',
|
|
||||||
self.object_pass['blender']['uri'])
|
|
||||||
bpy.ops.wm.link(
|
bpy.ops.wm.link(
|
||||||
filename=identification,
|
filename=reference.name,
|
||||||
directory=os.path.join(uri, 'Mesh')
|
directory=os.path.join(reference.location, 'Mesh')
|
||||||
)
|
)
|
||||||
bpy.context.active_object.data = bpy.data.meshes[identification]
|
bpy.context.active_object.data = bpy.data.meshes[reference.name]
|
||||||
|
|
||||||
|
|
||||||
class AddSubcontext(bpy.types.Operator):
|
class AddSubcontext(bpy.types.Operator):
|
||||||
|
|||||||
Reference in New Issue
Block a user