mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 22:50:21 +00:00
edit shape aspect attributes from UI
example - https://i.imgur.com/SzUEn6r.png
This commit is contained in:
@@ -58,6 +58,7 @@ classes = (
|
|||||||
operator.DisableEditingRepresentationItemShapeAspect,
|
operator.DisableEditingRepresentationItemShapeAspect,
|
||||||
operator.RemoveRepresentationItemFromShapeAspect,
|
operator.RemoveRepresentationItemFromShapeAspect,
|
||||||
prop.RepresentationItem,
|
prop.RepresentationItem,
|
||||||
|
prop.ShapeAspect,
|
||||||
prop.BIMObjectGeometryProperties,
|
prop.BIMObjectGeometryProperties,
|
||||||
prop.BIMGeometryProperties,
|
prop.BIMGeometryProperties,
|
||||||
ui.BIM_PT_placement,
|
ui.BIM_PT_placement,
|
||||||
|
|||||||
@@ -1715,6 +1715,12 @@ class EditRepresentationItemShapeAspect(bpy.types.Operator, Operator):
|
|||||||
ifc_file = tool.Ifc.get()
|
ifc_file = tool.Ifc.get()
|
||||||
|
|
||||||
shape_aspect = ifc_file.by_id(int(props.representation_item_shape_aspect))
|
shape_aspect = ifc_file.by_id(int(props.representation_item_shape_aspect))
|
||||||
|
|
||||||
|
# set attributes from UI
|
||||||
|
shape_aspect_attrs = props.shape_aspect_attrs
|
||||||
|
shape_aspect.Name = shape_aspect_attrs.name
|
||||||
|
shape_aspect.Description = shape_aspect_attrs.description
|
||||||
|
|
||||||
representation_item_id = props.items[props.active_item_index].ifc_definition_id
|
representation_item_id = props.items[props.active_item_index].ifc_definition_id
|
||||||
representation_item = ifc_file.by_id(representation_item_id)
|
representation_item = ifc_file.by_id(representation_item_id)
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
|
# along with BlenderBIM Add-on. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
import bpy
|
import bpy
|
||||||
|
import blenderbim.tool as tool
|
||||||
from blenderbim.bim.prop import StrProperty, Attribute
|
from blenderbim.bim.prop import StrProperty, Attribute
|
||||||
from blenderbim.bim.module.geometry.data import RepresentationsData
|
from blenderbim.bim.module.geometry.data import RepresentationsData
|
||||||
from bpy.types import PropertyGroup
|
from bpy.types import PropertyGroup
|
||||||
@@ -62,6 +63,20 @@ def get_shape_aspects(self, context):
|
|||||||
return RepresentationsData.data["shape_aspects"]
|
return RepresentationsData.data["shape_aspects"]
|
||||||
|
|
||||||
|
|
||||||
|
def get_material_constituents(self, context, edit_text):
|
||||||
|
# TODO: cache in data.py
|
||||||
|
return [m.Name for m in tool.Ifc.get().by_type("IfcMaterialConstituent") if m.Name]
|
||||||
|
|
||||||
|
|
||||||
|
def update_shape_aspect(self, context):
|
||||||
|
shape_aspect_id = self.representation_item_shape_aspect
|
||||||
|
attrs = self.shape_aspect_attrs
|
||||||
|
|
||||||
|
shape_aspect = tool.Ifc.get().by_id(int(shape_aspect_id))
|
||||||
|
attrs.name = shape_aspect.Name or ""
|
||||||
|
attrs.description = shape_aspect.Description or ""
|
||||||
|
|
||||||
|
|
||||||
class RepresentationItem(PropertyGroup):
|
class RepresentationItem(PropertyGroup):
|
||||||
name: StringProperty(name="Name")
|
name: StringProperty(name="Name")
|
||||||
surface_style: StringProperty(name="Surface Style")
|
surface_style: StringProperty(name="Surface Style")
|
||||||
@@ -71,6 +86,20 @@ class RepresentationItem(PropertyGroup):
|
|||||||
shape_aspect_id: IntProperty(name="Shape Aspect IFC ID")
|
shape_aspect_id: IntProperty(name="Shape Aspect IFC ID")
|
||||||
|
|
||||||
|
|
||||||
|
class ShapeAspect(PropertyGroup):
|
||||||
|
name: StringProperty(
|
||||||
|
name="Name",
|
||||||
|
description=(
|
||||||
|
"Note that IfcMaterialConstituent is applied based on shape aspects using the same name as material constituent.\n"
|
||||||
|
"In dropdown suggestions you can see names of existing material constituents."
|
||||||
|
),
|
||||||
|
search=get_material_constituents,
|
||||||
|
)
|
||||||
|
description: StringProperty(
|
||||||
|
name="Description",
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class BIMObjectGeometryProperties(PropertyGroup):
|
class BIMObjectGeometryProperties(PropertyGroup):
|
||||||
contexts: EnumProperty(items=get_contexts, name="Contexts")
|
contexts: EnumProperty(items=get_contexts, name="Contexts")
|
||||||
is_editing: BoolProperty(name="Is Editing", default=False)
|
is_editing: BoolProperty(name="Is Editing", default=False)
|
||||||
@@ -79,7 +108,10 @@ class BIMObjectGeometryProperties(PropertyGroup):
|
|||||||
is_editing_item_style: BoolProperty(name="Is Editing Item's Style", default=False)
|
is_editing_item_style: BoolProperty(name="Is Editing Item's Style", default=False)
|
||||||
representation_item_style: EnumProperty(items=get_styles, name="Representation Item Style")
|
representation_item_style: EnumProperty(items=get_styles, name="Representation Item Style")
|
||||||
is_editing_item_shape_aspect: BoolProperty(name="Is Editing Item's Shape Aspect", default=False)
|
is_editing_item_shape_aspect: BoolProperty(name="Is Editing Item's Shape Aspect", default=False)
|
||||||
representation_item_shape_aspect: EnumProperty(items=get_shape_aspects, name="Representation Item Shape Aspect")
|
representation_item_shape_aspect: EnumProperty(
|
||||||
|
items=get_shape_aspects, name="Representation Item Shape Aspect", update=update_shape_aspect
|
||||||
|
)
|
||||||
|
shape_aspect_attrs: PointerProperty(type=ShapeAspect)
|
||||||
|
|
||||||
|
|
||||||
class BIMGeometryProperties(PropertyGroup):
|
class BIMGeometryProperties(PropertyGroup):
|
||||||
|
|||||||
@@ -218,6 +218,11 @@ class BIM_PT_representation_items(Panel):
|
|||||||
row.prop(props, "representation_item_shape_aspect", icon="SHAPEKEY_DATA", text="")
|
row.prop(props, "representation_item_shape_aspect", icon="SHAPEKEY_DATA", text="")
|
||||||
row.operator("bim.edit_representation_item_shape_aspect", icon="CHECKMARK", text="")
|
row.operator("bim.edit_representation_item_shape_aspect", icon="CHECKMARK", text="")
|
||||||
row.operator("bim.disable_editing_representation_item_shape_aspect", icon="CANCEL", text="")
|
row.operator("bim.disable_editing_representation_item_shape_aspect", icon="CANCEL", text="")
|
||||||
|
|
||||||
|
shape_aspect_attrs = props.shape_aspect_attrs
|
||||||
|
self.layout.label(text="Shape Aspect Attributes:")
|
||||||
|
self.layout.prop(shape_aspect_attrs, "name")
|
||||||
|
self.layout.prop(shape_aspect_attrs, "description")
|
||||||
else:
|
else:
|
||||||
row.label(text=shape_aspect or "No Shape Aspect", icon="SHAPEKEY_DATA")
|
row.label(text=shape_aspect or "No Shape Aspect", icon="SHAPEKEY_DATA")
|
||||||
row.operator("bim.enable_editing_representation_item_shape_aspect", icon="GREASEPENCIL", text="")
|
row.operator("bim.enable_editing_representation_item_shape_aspect", icon="GREASEPENCIL", text="")
|
||||||
|
|||||||
Reference in New Issue
Block a user