mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-13 19:07:57 +00:00
Allow to add attributes from a drop down for ease of use
This commit is contained in:
@@ -285,9 +285,10 @@ class AddAttribute(bpy.types.Operator):
|
||||
bl_idname = 'bim.add_attribute'
|
||||
bl_label = 'Add Attribute'
|
||||
|
||||
# This is a temporary measure until we get a better UI
|
||||
def execute(self, context):
|
||||
bpy.context.active_object.ObjectProperties.attributes.add()
|
||||
if bpy.context.active_object.ObjectProperties.applicable_attributes:
|
||||
attribute = bpy.context.active_object.ObjectProperties.attributes.add()
|
||||
attribute.name = bpy.context.active_object.ObjectProperties.applicable_attributes
|
||||
return {'FINISHED'}
|
||||
|
||||
class RemoveAttribute(bpy.types.Operator):
|
||||
|
||||
@@ -60,8 +60,17 @@ class Pset(bpy.types.PropertyGroup):
|
||||
file: bpy.props.StringProperty(name="File")
|
||||
|
||||
class ObjectProperties(bpy.types.PropertyGroup):
|
||||
def getApplicableAttributes(self, context):
|
||||
if '/' in bpy.context.active_object.name \
|
||||
and bpy.context.active_object.name.split('/')[0] in ifc_schema.elements:
|
||||
return [(a['name'], a['name'], '') for a in
|
||||
ifc_schema.elements[bpy.context.active_object.name.split('/')[0]]['attributes']
|
||||
if bpy.context.active_object.ObjectProperties.attributes.find(a['name']) == -1]
|
||||
return []
|
||||
|
||||
attributes: bpy.props.CollectionProperty(name="Attributes", type=Attribute)
|
||||
psets: bpy.props.CollectionProperty(name="Psets", type=Pset)
|
||||
applicable_attributes: bpy.props.EnumProperty(items=getApplicableAttributes, name="Attribute Names")
|
||||
|
||||
class MaterialProperties(bpy.types.PropertyGroup):
|
||||
is_external: bpy.props.BoolProperty(name="Has External Definition")
|
||||
@@ -89,7 +98,8 @@ class ObjectPanel(bpy.types.Panel):
|
||||
row.operator('bim.generate_global_id')
|
||||
|
||||
layout.label(text="Attributes:")
|
||||
row = layout.row()
|
||||
row = layout.row(align=True)
|
||||
row.prop(bpy.context.active_object.ObjectProperties, 'applicable_attributes', text='')
|
||||
row.operator('bim.add_attribute')
|
||||
|
||||
for index, attribute in enumerate(bpy.context.active_object.ObjectProperties.attributes):
|
||||
|
||||
Reference in New Issue
Block a user