Utility to quickly set object colours, also colour mode is automatically changed now

This commit is contained in:
Dion Moult
2020-08-12 19:59:30 +10:00
parent 5db2a46369
commit 01d0d125a6
4 changed files with 41 additions and 0 deletions
@@ -179,6 +179,7 @@ if bpy is not None:
operator.CalculateFaceAreas,
operator.CalculateObjectVolumes,
operator.AddOpening,
operator.SetOverrideColour,
prop.StrProperty,
prop.Variable,
prop.Role,
@@ -255,6 +256,7 @@ if bpy is not None:
ui.BIM_PT_text,
ui.BIM_PT_modeling_utilities,
ui.BIM_PT_qto_utilities,
ui.BIM_PT_misc_utilities,
ui.BIM_UL_generic,
ui.BIM_UL_clash_sets,
ui.BIM_UL_constraints,
@@ -268,6 +268,8 @@ class ColourByClass(bpy.types.Operator):
if ifc_class not in ifc_classes:
ifc_classes[ifc_class] = next(colours)
obj.color = ifc_classes[ifc_class]
area = next(area for area in bpy.context.screen.areas if area.type == 'VIEW_3D')
area.spaces[0].shading.color_type = 'OBJECT'
return {'FINISHED'}
@@ -287,6 +289,8 @@ class ColourByAttribute(bpy.types.Operator):
if value not in values:
values[value] = next(colours)
obj.color = values[value]
area = next(area for area in bpy.context.screen.areas if area.type == 'VIEW_3D')
area.spaces[0].shading.color_type = 'OBJECT'
return {'FINISHED'}
@@ -310,6 +314,8 @@ class ColourByPset(bpy.types.Operator):
if value not in values:
values[value] = next(colours)
obj.color = values[value]
area = next(area for area in bpy.context.screen.areas if area.type == 'VIEW_3D')
area.spaces[0].shading.color_type = 'OBJECT'
return {'FINISHED'}
@@ -1392,6 +1398,8 @@ class VisualiseDiff(bpy.types.Operator):
obj.color = (0., 1., 0., .2)
elif global_id.string_value in diff['changed']:
obj.color = (0., 0., 1., .2)
area = next(area for area in bpy.context.screen.areas if area.type == 'VIEW_3D')
area.spaces[0].shading.color_type = 'OBJECT'
return {'FINISHED'}
@@ -3435,3 +3443,16 @@ class AddOpening(bpy.types.Operator):
modifier.operation = 'DIFFERENCE'
modifier.object = opening
return {'FINISHED'}
class SetOverrideColour(bpy.types.Operator):
bl_idname = 'bim.set_override_colour'
bl_label = 'Set Override Colour'
def execute(self, context):
result = 0
for obj in bpy.context.selected_objects:
obj.color = bpy.context.scene.BIMProperties.override_colour
area = next(area for area in bpy.context.screen.areas if area.type == 'VIEW_3D')
area.spaces[0].shading.color_type = 'OBJECT'
return {'FINISHED'}
@@ -1099,6 +1099,7 @@ class BIMProperties(PropertyGroup):
qto_result: StringProperty(default='', name='Qto Result')
area_unit: StringProperty(default='', name='IFC Area Unit')
volume_unit: StringProperty(default='', name='IFC Volume Unit')
override_colour: FloatVectorProperty(name='Override Colour', subtype='COLOR', default=(1, 0, 0, 1), min=0.0, max=1.0, size=4)
class BCFProperties(PropertyGroup):
+17
View File
@@ -1866,6 +1866,23 @@ class BIM_PT_qto_utilities(Panel):
row.operator("bim.calculate_object_volumes")
class BIM_PT_misc_utilities(Panel):
bl_idname = "BIM_PT_misc_utilities"
bl_label = "Miscellaneous"
bl_space_type = 'VIEW_3D'
bl_region_type = "UI"
bl_category = 'BlenderBIM'
def draw(self, context):
layout = self.layout
props = context.scene.BIMProperties
row = layout.row()
row.prop(props, 'override_colour', text='')
row = layout.row(align=True)
row.operator("bim.set_override_colour")
def ifc_units(self, context):
scene = context.scene
props = context.scene.BIMProperties