mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
Continuing adding tests for the refactored property support
This commit is contained in:
@@ -124,43 +124,52 @@ class EnablePsetEditing(bpy.types.Operator):
|
||||
continue # Other types not yet supported
|
||||
if prop_template.TemplateType == "P_SINGLEVALUE":
|
||||
self.load_single_value(prop_template, data)
|
||||
elif prop_template.TemplateType.startswith("Q_"):
|
||||
self.load_single_value(prop_template, data)
|
||||
elif prop_template.TemplateType == "P_ENUMERATEDVALUE":
|
||||
self.load_enumerated_value(prop_template, data)
|
||||
|
||||
def load_single_value(self, prop_template, data):
|
||||
try:
|
||||
data_type = ifcopenshell.util.attribute.get_primitive_type(
|
||||
IfcStore.get_schema().declaration_by_name(prop_template.PrimaryMeasureType or "IfcLabel")
|
||||
)
|
||||
except:
|
||||
# TODO: Occurs if the data type is something that exists in
|
||||
# IFC4 and not in IFC2X3. To fully fix this we need to
|
||||
# generate the IFC2X3 pset template definitions.
|
||||
return
|
||||
|
||||
prop = self.props.properties.add()
|
||||
prop.name = prop_template.Name
|
||||
prop.value_type = "IfcPropertySingleValue"
|
||||
metadata = prop.metadata
|
||||
metadata.name = prop_template.Name
|
||||
metadata.is_null = data.get(prop_template.Name, None) is None
|
||||
metadata.is_optional = True
|
||||
metadata.is_uri = prop_template.PrimaryMeasureType == "IfcURIReference"
|
||||
metadata.data_type = data_type
|
||||
metadata.data_type = self.get_data_type(prop_template)
|
||||
|
||||
if data_type == "string":
|
||||
if metadata.data_type == "string":
|
||||
metadata.string_value = "" if metadata.is_null else data[prop_template.Name]
|
||||
elif data_type == "integer":
|
||||
elif metadata.data_type == "integer":
|
||||
metadata.int_value = 0 if metadata.is_null else data[prop_template.Name]
|
||||
elif data_type == "float":
|
||||
elif metadata.data_type == "float":
|
||||
metadata.float_value = 0.0 if metadata.is_null else data[prop_template.Name]
|
||||
elif data_type == "boolean":
|
||||
elif metadata.data_type == "boolean":
|
||||
metadata.bool_value = False if metadata.is_null else data[prop_template.Name]
|
||||
|
||||
def get_data_type(self, prop_template):
|
||||
if prop_template.TemplateType in ["Q_LENGTH", "Q_AREA", "Q_VOLUME", "Q_WEIGHT", "Q_TIME"]:
|
||||
return "float"
|
||||
elif prop_template.TemplateType == "Q_COUNT":
|
||||
return "integer"
|
||||
try:
|
||||
return ifcopenshell.util.attribute.get_primitive_type(
|
||||
IfcStore.get_schema().declaration_by_name(prop_template.PrimaryMeasureType or "IfcLabel")
|
||||
)
|
||||
except:
|
||||
# TODO: Occurs if the data type is something that exists in
|
||||
# IFC4 and not in IFC2X3. To fully fix this we need to
|
||||
# generate the IFC2X3 pset template definitions.
|
||||
pass
|
||||
|
||||
def load_enumerated_value(self, prop_template, data):
|
||||
enum_items = [v.wrappedValue for v in prop_template.Enumerators.EnumerationValues]
|
||||
selected_enum_items = data.get(prop_template.Name, [])
|
||||
|
||||
prop = self.props.properties.add()
|
||||
prop.name = prop_template.Name
|
||||
prop.value_type = "IfcPropertyEnumeratedValue"
|
||||
metadata = prop.metadata
|
||||
metadata.name = prop_template.Name
|
||||
@@ -358,7 +367,7 @@ class GuessQuantity(bpy.types.Operator):
|
||||
self.qto_calculator = QtoCalculator()
|
||||
obj = context.active_object
|
||||
prop = obj.PsetProperties.properties.get(self.prop)
|
||||
prop.float_value = self.guess_quantity(obj, context)
|
||||
prop.metadata.float_value = self.guess_quantity(obj, context)
|
||||
return {"FINISHED"}
|
||||
|
||||
def guess_quantity(self, obj, context):
|
||||
@@ -402,7 +411,7 @@ class CopyPropertyToSelection(bpy.types.Operator, Operator):
|
||||
def _execute(self, context):
|
||||
is_pset = tool.Ifc.get().by_id(context.active_object.PsetProperties.active_pset_id).is_a("IfcPropertySet")
|
||||
pset_name = context.active_object.PsetProperties.active_pset_name
|
||||
prop_value = context.active_object.PsetProperties.properties.get(self.name).get_value()
|
||||
prop_value = context.active_object.PsetProperties.properties.get(self.name).metadata.get_value()
|
||||
for obj in context.selected_objects:
|
||||
core.copy_property_to_selection(
|
||||
tool.Ifc,
|
||||
|
||||
@@ -162,7 +162,7 @@ class PsetProperties(PropertyGroup):
|
||||
class MaterialPsetProperties(PropertyGroup):
|
||||
active_pset_id: IntProperty(name="Active Pset ID")
|
||||
active_pset_name: StringProperty(name="Pset Name")
|
||||
properties: CollectionProperty(name="Properties", type=Attribute)
|
||||
properties: CollectionProperty(name="Properties", type=IfcProperty)
|
||||
pset_name: EnumProperty(items=getMaterialPsetNames, name="Pset Name")
|
||||
|
||||
|
||||
@@ -184,14 +184,14 @@ class ResourcePsetProperties(PropertyGroup):
|
||||
class ProfilePsetProperties(PropertyGroup):
|
||||
active_pset_id: IntProperty(name="Active Pset ID")
|
||||
active_pset_name: StringProperty(name="Pset Name")
|
||||
properties: CollectionProperty(name="Properties", type=Attribute)
|
||||
properties: CollectionProperty(name="Properties", type=IfcProperty)
|
||||
pset_name: EnumProperty(items=getProfilePsetNames, name="Pset Name")
|
||||
|
||||
|
||||
class WorkSchedulePsetProperties(PropertyGroup):
|
||||
active_pset_id: IntProperty(name="Active Pset ID")
|
||||
active_pset_name: StringProperty(name="Pset Name")
|
||||
properties: CollectionProperty(name="Properties", type=Attribute)
|
||||
properties: CollectionProperty(name="Properties", type=IfcProperty)
|
||||
pset_name: EnumProperty(items=getWorkSchedulePsetNames, name="Pset Name")
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,78 @@
|
||||
@pset
|
||||
Feature: Pset
|
||||
|
||||
Scenario: Enable pset editing - object
|
||||
Given an empty IFC project
|
||||
And I add a cube
|
||||
And the object "Cube" is selected
|
||||
And I set "scene.BIMRootProperties.ifc_class" to "IfcWall"
|
||||
And I press "bim.assign_class"
|
||||
And the object "IfcWall/Cube" is selected
|
||||
And I set "active_object.PsetProperties.pset_name" to "Pset_WallCommon"
|
||||
And I press "bim.add_pset(obj='IfcWall/Cube', obj_type='Object')"
|
||||
And the variable "pset" is "{ifc}.by_type('IfcPropertySet')[-1].id()"
|
||||
When I press "bim.enable_pset_editing(pset_id={pset}, obj='IfcWall/Cube', obj_type='Object')"
|
||||
Then nothing happens
|
||||
|
||||
Scenario: Enable pset editing - material
|
||||
Given an empty IFC project
|
||||
And I add a cube
|
||||
And the object "Cube" is selected
|
||||
And I set "scene.BIMRootProperties.ifc_class" to "IfcWall"
|
||||
And I press "bim.assign_class"
|
||||
And I press "bim.add_material(obj='')"
|
||||
And I set "active_object.BIMObjectMaterialProperties.material_type" to "IfcMaterial"
|
||||
And I press "bim.assign_material"
|
||||
And the object "IfcWall/Cube" is selected
|
||||
And I press "bim.add_pset(obj='Default', obj_type='Material')"
|
||||
And the variable "pset" is "{ifc}.by_type('IfcMaterialProperties')[-1].id()"
|
||||
When I press "bim.enable_pset_editing(pset_id={pset}, obj='Default', obj_type='Material')"
|
||||
Then nothing happens
|
||||
|
||||
Scenario: Enable pset editing - profile
|
||||
Given an empty IFC project
|
||||
And I add an empty
|
||||
And the object "Empty" is selected
|
||||
And I set "scene.BIMRootProperties.ifc_product" to "IfcElementType"
|
||||
And I set "scene.BIMRootProperties.ifc_class" to "IfcWallType"
|
||||
And I press "bim.assign_class"
|
||||
And I press "bim.add_material(obj='')"
|
||||
And I set "active_object.BIMObjectMaterialProperties.material_type" to "IfcMaterialProfileSet"
|
||||
And I press "bim.assign_material"
|
||||
And I press "bim.enable_editing_assigned_material()"
|
||||
And the variable "profile_set" is "{ifc}.by_type('IfcMaterialProfileSet')[-1].id()"
|
||||
And I press "bim.add_profile(profile_set={profile_set})"
|
||||
And the variable "material_profile" is "{ifc}.by_type('IfcMaterialProfile')[-1].id()"
|
||||
And I press "bim.enable_editing_material_set_item(material_set_item={material_profile})"
|
||||
And I set "active_object.BIMObjectMaterialProperties.profile_classes" to "IfcParameterizedProfileDef"
|
||||
And I press "bim.assign_parameterized_profile(ifc_class="IfcIShapeProfileDef", material_profile={material_profile})"
|
||||
And I press "bim.load_profiles"
|
||||
And I set "scene.ProfilePsetProperties.pset_name" to "Pset_ProfileMechanical"
|
||||
And I press "bim.add_pset(obj_type='Profile')"
|
||||
And the variable "pset" is "{ifc}.by_type('IfcProfileProperties')[-1].id()"
|
||||
When I press "bim.enable_pset_editing(pset_id={pset}, obj='', obj_type='Profile')"
|
||||
Then nothing happens
|
||||
|
||||
Scenario: Enable pset editing - work schedule
|
||||
Given an empty IFC project
|
||||
And I press "bim.add_work_schedule"
|
||||
And the variable "work_schedule" is "{ifc}.by_type('IfcWorkSchedule')[0].id()"
|
||||
And I press "bim.enable_editing_tasks(work_schedule={work_schedule})"
|
||||
And I set "scene.WorkSchedulePsetProperties.pset_name" to "Pset_WorkControlCommon"
|
||||
And I press "bim.add_pset(obj_type='WorkSchedule')"
|
||||
And the variable "pset" is "{ifc}.by_type('IfcPropertySet')[-1].id()"
|
||||
When I press "bim.enable_pset_editing(pset_id={pset}, obj='', obj_type='WorkSchedule')"
|
||||
|
||||
Scenario: Enable pset editing - resource
|
||||
Given an empty IFC project
|
||||
And I press "bim.load_resources"
|
||||
And I press "bim.add_resource(ifc_class='IfcSubContractResource', resource=0)"
|
||||
And I set "scene.ResourcePsetProperties.pset_name" to "Pset_ConstructionResource"
|
||||
And I press "bim.add_pset(obj_type='Resource')"
|
||||
And the variable "pset" is "{ifc}.by_type('IfcPropertySet')[-1].id()"
|
||||
When I press "bim.enable_pset_editing(pset_id={pset}, obj='', obj_type='Resource')"
|
||||
Then nothing happens
|
||||
|
||||
Scenario: Copy property to selected - copy property
|
||||
Given an empty IFC project
|
||||
And I add a cube
|
||||
@@ -17,26 +89,6 @@ Scenario: Copy property to selected - copy property
|
||||
And I press "bim.add_pset(obj='IfcWall/Cube.001', obj_type='Object')"
|
||||
And the variable "pset" is "{ifc}.by_type('IfcPropertySet')[-1].id()"
|
||||
And I press "bim.enable_pset_editing(obj='IfcWall/Cube.001', obj_type='Object', pset_id={pset})"
|
||||
And I set "active_object.PsetProperties.properties[2].string_value" to "Foo"
|
||||
And I set "active_object.PsetProperties.properties[2].metadata.string_value" to "Foo"
|
||||
When I press "bim.copy_property_to_selection(name='FireRating')"
|
||||
Then nothing happens
|
||||
|
||||
Scenario: Copy property to selected - copy quantity
|
||||
Given an empty IFC project
|
||||
And I add a cube
|
||||
And the object "Cube" is selected
|
||||
And I set "scene.BIMRootProperties.ifc_class" to "IfcWall"
|
||||
And I press "bim.assign_class"
|
||||
And I add a cube
|
||||
And the object "Cube" is selected
|
||||
And I set "scene.BIMRootProperties.ifc_class" to "IfcWall"
|
||||
And I press "bim.assign_class"
|
||||
And the object "IfcWall/Cube" is selected
|
||||
And additionally the object "IfcWall/Cube.001" is selected
|
||||
And I set "active_object.PsetProperties.pset_name" to "Pset_BuildingElementCommon"
|
||||
And I press "bim.add_qto(obj='IfcWall/Cube.001', obj_type='Object')"
|
||||
And the variable "qto" is "{ifc}.by_type('IfcQuantitySet')[-1].id()"
|
||||
And I press "bim.enable_pset_editing(obj='IfcWall/Cube.001', obj_type='Object', pset_id={qto})"
|
||||
And I set "active_object.PsetProperties.properties[0].float_value" to "1"
|
||||
When I press "bim.copy_property_to_selection(name='Length')"
|
||||
Then nothing happens
|
||||
|
||||
Reference in New Issue
Block a user