mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-28 03:05:33 +00:00
Allow fetching Eevee or Cycles materials from a material pass file
This commit is contained in:
@@ -57,6 +57,7 @@ classes = (
|
|||||||
operator.UnassignClassification,
|
operator.UnassignClassification,
|
||||||
operator.RemoveClassification,
|
operator.RemoveClassification,
|
||||||
operator.FetchLibraryInformation,
|
operator.FetchLibraryInformation,
|
||||||
|
operator.FetchExternalMaterial,
|
||||||
prop.BIMProperties,
|
prop.BIMProperties,
|
||||||
prop.BIMLibrary,
|
prop.BIMLibrary,
|
||||||
prop.MapConversion,
|
prop.MapConversion,
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
import os
|
||||||
import bpy
|
import bpy
|
||||||
import time
|
import time
|
||||||
import json
|
import json
|
||||||
@@ -641,6 +642,37 @@ class RemoveClassification(bpy.types.Operator):
|
|||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
|
||||||
|
class FetchExternalMaterial(bpy.types.Operator):
|
||||||
|
bl_idname = 'bim.fetch_external_material'
|
||||||
|
bl_label = 'Fetch External Material'
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
location = bpy.context.active_object.active_material.BIMMaterialProperties.location
|
||||||
|
if location[-6:] != '.mpass':
|
||||||
|
return {'FINISHED'}
|
||||||
|
with open(location) as f:
|
||||||
|
self.material_pass = json.load(f)
|
||||||
|
if bpy.context.scene.render.engine == 'BLENDER_EEVEE' \
|
||||||
|
and 'eevee' in self.material_pass:
|
||||||
|
self.fetch_eevee_or_cycles('eevee')
|
||||||
|
elif bpy.context.scene.render.engine == 'CYCLES' \
|
||||||
|
and 'cycles' in self.material_pass:
|
||||||
|
self.fetch_eevee_or_cycles('cycles')
|
||||||
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
def fetch_eevee_or_cycles(self, name):
|
||||||
|
identification = bpy.context.active_object.active_material.BIMMaterialProperties.identification
|
||||||
|
bpy.ops.wm.link(
|
||||||
|
filename=identification,
|
||||||
|
directory=os.path.join(self.material_pass[name]['uri'], 'Material')
|
||||||
|
)
|
||||||
|
for material in bpy.data.materials:
|
||||||
|
if material.name == identification \
|
||||||
|
and material.library:
|
||||||
|
bpy.context.active_object.material_slots[0].material = material
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
class FetchLibraryInformation(bpy.types.Operator):
|
class FetchLibraryInformation(bpy.types.Operator):
|
||||||
bl_idname = 'bim.fetch_library_information'
|
bl_idname = 'bim.fetch_library_information'
|
||||||
bl_label = 'Fetch Library Information'
|
bl_label = 'Fetch Library Information'
|
||||||
|
|||||||
@@ -143,6 +143,9 @@ class BIM_PT_material(Panel):
|
|||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.prop(props, 'name')
|
row.prop(props, 'name')
|
||||||
|
|
||||||
|
row = layout.row()
|
||||||
|
row.operator('bim.fetch_external_material')
|
||||||
|
|
||||||
|
|
||||||
class BIM_PT_gis(Panel):
|
class BIM_PT_gis(Panel):
|
||||||
bl_label = 'IFC Georeferencing'
|
bl_label = 'IFC Georeferencing'
|
||||||
|
|||||||
Reference in New Issue
Block a user