mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 06:21:40 +00:00
Add assign context operator and minor UI cleanup
This commit is contained in:
@@ -86,6 +86,7 @@ if bpy is not None:
|
|||||||
operator.CreateView,
|
operator.CreateView,
|
||||||
operator.ActivateView,
|
operator.ActivateView,
|
||||||
operator.ExecuteIfcDiff,
|
operator.ExecuteIfcDiff,
|
||||||
|
operator.AssignContext,
|
||||||
prop.Subcontext,
|
prop.Subcontext,
|
||||||
prop.BIMProperties,
|
prop.BIMProperties,
|
||||||
prop.DocProperties,
|
prop.DocProperties,
|
||||||
|
|||||||
@@ -947,6 +947,7 @@ class GenerateDigitalTwin(bpy.types.Operator):
|
|||||||
# Does absolutely nothing at all :D
|
# Does absolutely nothing at all :D
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
|
||||||
class ActivateView(bpy.types.Operator):
|
class ActivateView(bpy.types.Operator):
|
||||||
bl_idname = 'bim.activate_view'
|
bl_idname = 'bim.activate_view'
|
||||||
bl_label = 'Activate View'
|
bl_label = 'Activate View'
|
||||||
@@ -965,3 +966,32 @@ class ActivateView(bpy.types.Operator):
|
|||||||
bpy.context.view_layer.layer_collection.children['Views'].children[camera.users_collection[0].name].hide_viewport = False
|
bpy.context.view_layer.layer_collection.children['Views'].children[camera.users_collection[0].name].hide_viewport = False
|
||||||
bpy.data.collections.get(camera.users_collection[0].name).hide_render = False
|
bpy.data.collections.get(camera.users_collection[0].name).hide_render = False
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
|
||||||
|
class AssignContext(bpy.types.Operator):
|
||||||
|
bl_idname = 'bim.assign_context'
|
||||||
|
bl_label = 'Assign Context'
|
||||||
|
|
||||||
|
def execute(self, context):
|
||||||
|
if not self.is_mesh_context_sensitive(bpy.context.active_object.data.name):
|
||||||
|
bpy.context.active_object.data.name = '{}/{}/{}/{}'.format(
|
||||||
|
bpy.context.scene.BIMProperties.available_contexts,
|
||||||
|
bpy.context.scene.BIMProperties.available_subcontexts,
|
||||||
|
bpy.context.scene.BIMProperties.available_target_views,
|
||||||
|
bpy.context.active_object.data.name
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
bpy.context.active_object.data.name = '{}/{}/{}/{}'.format(
|
||||||
|
bpy.context.scene.BIMProperties.available_contexts,
|
||||||
|
bpy.context.scene.BIMProperties.available_subcontexts,
|
||||||
|
bpy.context.scene.BIMProperties.available_target_views,
|
||||||
|
bpy.context.active_object.data.name.split('/')[3]
|
||||||
|
)
|
||||||
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
def is_mesh_context_sensitive(self, name):
|
||||||
|
return '/' in name \
|
||||||
|
and ( \
|
||||||
|
name[0:6] == 'Model/' \
|
||||||
|
or name[0:5] == 'Plan/' \
|
||||||
|
)
|
||||||
|
|||||||
@@ -276,6 +276,7 @@ class BIMProperties(PropertyGroup):
|
|||||||
has_plan_context: BoolProperty(name="Has Plan Context", default=False)
|
has_plan_context: BoolProperty(name="Has Plan Context", default=False)
|
||||||
model_subcontexts: CollectionProperty(name='Model Subcontexts', type=Subcontext)
|
model_subcontexts: CollectionProperty(name='Model Subcontexts', type=Subcontext)
|
||||||
plan_subcontexts: CollectionProperty(name='Plan Subcontexts', type=Subcontext)
|
plan_subcontexts: CollectionProperty(name='Plan Subcontexts', type=Subcontext)
|
||||||
|
available_contexts: EnumProperty(items=[('Model', 'Model', ''), ('Plan', 'Plan', '')], name="Available Contexts")
|
||||||
available_subcontexts: EnumProperty(items=getSubcontexts, name="Available Subcontexts")
|
available_subcontexts: EnumProperty(items=getSubcontexts, name="Available Subcontexts")
|
||||||
available_target_views: EnumProperty(items=getTargetViews, name="Available Target Views")
|
available_target_views: EnumProperty(items=getTargetViews, name="Available Target Views")
|
||||||
|
|
||||||
|
|||||||
@@ -95,6 +95,14 @@ class BIM_PT_mesh(Panel):
|
|||||||
return
|
return
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
props = context.active_object.data.BIMMeshProperties
|
props = context.active_object.data.BIMMeshProperties
|
||||||
|
|
||||||
|
row = layout.row(align=True)
|
||||||
|
row.prop(bpy.context.scene.BIMProperties, 'available_contexts', text='')
|
||||||
|
row.prop(bpy.context.scene.BIMProperties, 'available_subcontexts', text='')
|
||||||
|
row.prop(bpy.context.scene.BIMProperties, 'available_target_views', text='')
|
||||||
|
row = layout.row()
|
||||||
|
row.operator('bim.assign_context')
|
||||||
|
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.prop(props, 'is_wireframe')
|
row.prop(props, 'is_wireframe')
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
@@ -271,9 +279,12 @@ class BIM_PT_context(Panel):
|
|||||||
|
|
||||||
for context in ['model', 'plan']:
|
for context in ['model', 'plan']:
|
||||||
row = layout.row(align=True)
|
row = layout.row(align=True)
|
||||||
row.prop(props, 'has_{}_context'.format(context))
|
row.prop(props, f'has_{context}_context')
|
||||||
layout.label(text="Geometric Representation Subcontexts:")
|
|
||||||
|
|
||||||
|
if not getattr(props, f'has_{context}_context'):
|
||||||
|
continue
|
||||||
|
|
||||||
|
layout.label(text="Geometric Representation Subcontexts:")
|
||||||
row = layout.row(align=True)
|
row = layout.row(align=True)
|
||||||
row.prop(props, 'available_subcontexts', text='')
|
row.prop(props, 'available_subcontexts', text='')
|
||||||
row.prop(props, 'available_target_views', text='')
|
row.prop(props, 'available_target_views', text='')
|
||||||
|
|||||||
Reference in New Issue
Block a user