mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-16 02:24:30 +00:00
Fix #2286. Classifications can now be added for cost items.
This commit is contained in:
@@ -148,6 +148,10 @@ def get_obj_ifc_definition_id(context, obj, obj_type):
|
||||
return context.scene.BIMTaskTreeProperties.tasks[
|
||||
context.scene.BIMWorkScheduleProperties.active_task_index
|
||||
].ifc_definition_id
|
||||
elif obj_type == "Cost":
|
||||
return context.scene.BIMCostProperties.cost_items[
|
||||
context.scene.BIMCostProperties.active_cost_item_index
|
||||
].ifc_definition_id
|
||||
elif obj_type == "Resource":
|
||||
return context.scene.BIMResourceTreeProperties.resources[
|
||||
context.scene.BIMResourceProperties.active_resource_index
|
||||
|
||||
@@ -39,6 +39,7 @@ classes = (
|
||||
ui.BIM_PT_classifications,
|
||||
ui.BIM_PT_classification_references,
|
||||
ui.BIM_PT_material_classifications,
|
||||
ui.BIM_PT_cost_classifications,
|
||||
ui.BIM_UL_classifications,
|
||||
)
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ def refresh():
|
||||
ClassificationsData.is_loaded = False
|
||||
ClassificationReferencesData.is_loaded = False
|
||||
MaterialClassificationsData.is_loaded = False
|
||||
CostClassificationsData.is_loaded = False
|
||||
|
||||
|
||||
class ClassificationsData:
|
||||
@@ -114,3 +115,27 @@ class MaterialClassificationsData(ReferencesData):
|
||||
del data["ReferencedSource"]
|
||||
results.append(data)
|
||||
return results
|
||||
|
||||
|
||||
class CostClassificationsData(ReferencesData):
|
||||
data = {}
|
||||
is_loaded = False
|
||||
|
||||
@classmethod
|
||||
def load(cls):
|
||||
cls.is_loaded = True
|
||||
cls.data["references"] = cls.references()
|
||||
cls.data["is_available_classification_added"] = cls.is_available_classification_added()
|
||||
|
||||
@classmethod
|
||||
def references(cls):
|
||||
results = []
|
||||
element = tool.Ifc.get().by_id(bpy.context.scene.BIMCostProperties.cost_items[
|
||||
bpy.context.scene.BIMCostProperties.active_cost_item_index
|
||||
].ifc_definition_id)
|
||||
if element:
|
||||
for reference in ifcopenshell.util.classification.get_references(element):
|
||||
data = reference.get_info()
|
||||
del data["ReferencedSource"]
|
||||
results.append(data)
|
||||
return results
|
||||
|
||||
@@ -25,6 +25,7 @@ from blenderbim.bim.module.classification.data import (
|
||||
ClassificationsData,
|
||||
ClassificationReferencesData,
|
||||
MaterialClassificationsData,
|
||||
CostClassificationsData,
|
||||
)
|
||||
|
||||
|
||||
@@ -200,6 +201,30 @@ class BIM_PT_material_classifications(Panel, ReferenceUI):
|
||||
self.draw_ui(context)
|
||||
|
||||
|
||||
class BIM_PT_cost_classifications(Panel, ReferenceUI):
|
||||
bl_label = "IFC Cost Classifications"
|
||||
bl_idname = "BIM_PT_cost_classifications"
|
||||
bl_options = {"DEFAULT_CLOSED"}
|
||||
bl_space_type = "PROPERTIES"
|
||||
bl_region_type = "WINDOW"
|
||||
bl_context = "scene"
|
||||
bl_parent_id = "BIM_PT_cost_schedules"
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
if not tool.Ifc.get():
|
||||
return False
|
||||
return bool(context.scene.BIMCostProperties.cost_items)
|
||||
|
||||
def draw(self, context):
|
||||
if not CostClassificationsData.is_loaded:
|
||||
CostClassificationsData.load()
|
||||
self.data = CostClassificationsData
|
||||
self.obj = ""
|
||||
self.obj_type = "Cost"
|
||||
self.draw_ui(context)
|
||||
|
||||
|
||||
class BIM_UL_classifications(UIList):
|
||||
def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
|
||||
if item:
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
import bpy
|
||||
import ifcopenshell.api
|
||||
from blenderbim.bim.ifc import IfcStore
|
||||
from blenderbim.bim.module.classification.data import CostClassificationsData
|
||||
from ifcopenshell.api.cost.data import Data
|
||||
from ifcopenshell.api.pset.data import Data as PsetData
|
||||
from blenderbim.bim.prop import StrProperty, Attribute
|
||||
@@ -164,6 +165,7 @@ def update_active_cost_item_index(self, context):
|
||||
bpy.ops.bim.load_cost_item_types()
|
||||
else:
|
||||
bpy.ops.bim.load_cost_item_quantities()
|
||||
CostClassificationsData.load()
|
||||
|
||||
|
||||
def update_cost_item_identification(self, context):
|
||||
|
||||
@@ -6,6 +6,7 @@ markers =
|
||||
brick
|
||||
classification
|
||||
context
|
||||
cost
|
||||
debug
|
||||
demo
|
||||
document
|
||||
|
||||
@@ -216,3 +216,34 @@ Scenario: Remove classification reference - material
|
||||
And I press "bim.add_classification_reference(reference={reference}, obj='Material', obj_type='Material')"
|
||||
When I press "bim.remove_classification_reference(reference={reference}, obj='Material', obj_type='Material')"
|
||||
Then nothing happens
|
||||
|
||||
Scenario: Add classification reference - cost
|
||||
Given an empty IFC project
|
||||
And I press "bim.load_classification_library(filepath='{cwd}/test/files/classification.ifc')"
|
||||
And the variable "classification" is "{classification_ifc}.by_type('IfcClassification')[0].id()"
|
||||
And I set "scene.BIMClassificationProperties.available_classifications" to "{classification}"
|
||||
And I press "bim.add_classification"
|
||||
And I press "bim.add_cost_schedule"
|
||||
And the variable "cost_schedule" is "{ifc}.by_type('IfcCostSchedule')[0].id()"
|
||||
And I press "bim.enable_editing_cost_items(cost_schedule={cost_schedule})"
|
||||
And I press "bim.add_summary_cost_item(cost_schedule={cost_schedule})"
|
||||
And I press "bim.change_classification_level(parent_id={classification})"
|
||||
And the variable "reference" is "{classification_ifc}.by_type('IfcClassificationReference')[0].id()"
|
||||
When I press "bim.add_classification_reference(reference={reference}, obj='', obj_type='Cost')"
|
||||
Then nothing happens
|
||||
|
||||
Scenario: Remove classification reference - cost
|
||||
Given an empty IFC project
|
||||
And I press "bim.load_classification_library(filepath='{cwd}/test/files/classification.ifc')"
|
||||
And the variable "classification" is "{classification_ifc}.by_type('IfcClassification')[0].id()"
|
||||
And I set "scene.BIMClassificationProperties.available_classifications" to "{classification}"
|
||||
And I press "bim.add_classification"
|
||||
And I press "bim.add_cost_schedule"
|
||||
And the variable "cost_schedule" is "{ifc}.by_type('IfcCostSchedule')[0].id()"
|
||||
And I press "bim.enable_editing_cost_items(cost_schedule={cost_schedule})"
|
||||
And I press "bim.add_summary_cost_item(cost_schedule={cost_schedule})"
|
||||
And I press "bim.change_classification_level(parent_id={classification})"
|
||||
And the variable "reference" is "{classification_ifc}.by_type('IfcClassificationReference')[0].id()"
|
||||
And I press "bim.add_classification_reference(reference={reference}, obj='', obj_type='Cost')"
|
||||
When I press "bim.remove_classification_reference(reference={reference}, obj='', obj_type='Cost')"
|
||||
Then nothing happens
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
@cost
|
||||
Feature: Cost
|
||||
|
||||
Scenario: Add cost schedule
|
||||
Given an empty IFC project
|
||||
When I press "bim.add_cost_schedule"
|
||||
Then nothing happens
|
||||
|
||||
Scenario: Enable editing cost items
|
||||
Given an empty IFC project
|
||||
When I press "bim.add_cost_schedule"
|
||||
And the variable "cost_schedule" is "{ifc}.by_type('IfcCostSchedule')[0].id()"
|
||||
And I press "bim.enable_editing_cost_items(cost_schedule={cost_schedule})"
|
||||
Then nothing happens
|
||||
|
||||
Scenario: Add summary cost item
|
||||
Given an empty IFC project
|
||||
When I press "bim.add_cost_schedule"
|
||||
And the variable "cost_schedule" is "{ifc}.by_type('IfcCostSchedule')[0].id()"
|
||||
And I press "bim.enable_editing_cost_items(cost_schedule={cost_schedule})"
|
||||
And I press "bim.add_summary_cost_item(cost_schedule={cost_schedule})"
|
||||
Then nothing happens
|
||||
Reference in New Issue
Block a user