mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
black .
This commit is contained in:
@@ -555,7 +555,8 @@ class ImportCostScheduleCsv(bpy.types.Operator, ImportHelper, tool.Ifc.Operator)
|
||||
cost_schedule = core.import_cost_schedule_csv(tool.Cost, self.filepath, self.is_schedule_of_rates)
|
||||
core.add_csv_filepath(tool.Cost, self.filepath, self.is_schedule_of_rates, cost_schedule)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
|
||||
class RefreshCostScheduleCsv(bpy.types.Operator, tool.Ifc.Operator):
|
||||
bl_idname = "bim.refresh_cost_schedule_csv"
|
||||
bl_label = "Refresh Cost Schedule CSV"
|
||||
@@ -566,6 +567,7 @@ class RefreshCostScheduleCsv(bpy.types.Operator, tool.Ifc.Operator):
|
||||
core.refresh_cost_schedule_csv(tool.Ifc, tool.Cost)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class AddCostColumn(bpy.types.Operator):
|
||||
bl_idname = "bim.add_cost_column"
|
||||
bl_label = "Add Cost Column"
|
||||
|
||||
@@ -166,6 +166,7 @@ class CostItemQuantity(PropertyGroup):
|
||||
unit_symbol: str
|
||||
total_cost_quantity: float
|
||||
|
||||
|
||||
class CostItemsMapping(PropertyGroup):
|
||||
cost_item_id: IntProperty(name="cost_item_id")
|
||||
csv_filepath: StringProperty(name="filepath")
|
||||
@@ -174,6 +175,7 @@ class CostItemsMapping(PropertyGroup):
|
||||
cost_item_id: int
|
||||
csv_filepath: str
|
||||
|
||||
|
||||
class CostItemType(PropertyGroup):
|
||||
name: StringProperty(name="Name")
|
||||
ifc_definition_id: IntProperty(name="IFC Definition ID")
|
||||
|
||||
@@ -71,19 +71,26 @@ class BIM_PT_cost_schedules(Panel):
|
||||
text="Currently editing: {}[{}]".format(cost_schedule["name"], cost_schedule["predefined_type"]),
|
||||
icon="LINENUMBERS_ON",
|
||||
)
|
||||
|
||||
|
||||
row0 = self.layout.row(align=True)
|
||||
col = row0.column()
|
||||
col.label(text="Linked CSV:")
|
||||
row_1 = col.row(align=True)
|
||||
if self.props.active_cost_schedule_id in [item.cost_item_id for item in self.props.cost_schedule_files]:
|
||||
file = next((item.csv_filepath for item in self.props.cost_schedule_files if item.cost_item_id == self.props.active_cost_schedule_id), None)
|
||||
file = next(
|
||||
(
|
||||
item.csv_filepath
|
||||
for item in self.props.cost_schedule_files
|
||||
if item.cost_item_id == self.props.active_cost_schedule_id
|
||||
),
|
||||
None,
|
||||
)
|
||||
row_1.label(text=file)
|
||||
row_1.operator("bim.refresh_cost_schedule_csv", icon="FILE_REFRESH", text="")
|
||||
else:
|
||||
row_1.label(text="No CSV file found")
|
||||
row_1.operator("bim.import_cost_schedule_csv", icon="IMPORT", text="")
|
||||
|
||||
|
||||
grid = self.layout.grid_flow(columns=2, even_columns=True)
|
||||
col = grid.column()
|
||||
row1 = col.row(align=True)
|
||||
@@ -380,13 +387,13 @@ class BIM_PT_cost_item_types(Panel):
|
||||
has_quantity_names = CostProp.get_resource_quantity_names(self, context)
|
||||
|
||||
row2 = col.row(align=True)
|
||||
#row2.label(text="Resources")
|
||||
# row2.label(text="Resources")
|
||||
total_cost_item_resources = len(self.props.cost_item_resources)
|
||||
row2.label(text="Resources({})".format(total_cost_item_resources))
|
||||
|
||||
op = row2.operator("bim.calculate_cost_item_resource_value", text="", icon="DISC")
|
||||
op.cost_item = cost_item.ifc_definition_id
|
||||
|
||||
|
||||
rtprops = context.scene.BIMResourceTreeProperties
|
||||
rprops = context.scene.BIMResourceProperties
|
||||
if rtprops.resources and rprops.active_resource_index < len(rtprops.resources):
|
||||
|
||||
@@ -1502,9 +1502,8 @@ class CreateDrawing(bpy.types.Operator):
|
||||
|
||||
def move_elements_to_top(self, root):
|
||||
group = root.find("{http://www.w3.org/2000/svg}g")
|
||||
bringtofront = ifcopenshell.util.element.get_pset(self.camera_element, "EPset_Drawing", "BringToFront") or ''
|
||||
bringtofront = [item.strip() for item in bringtofront.split(',') if item.strip()]
|
||||
|
||||
bringtofront = ifcopenshell.util.element.get_pset(self.camera_element, "EPset_Drawing", "BringToFront") or ""
|
||||
bringtofront = [item.strip() for item in bringtofront.split(",") if item.strip()]
|
||||
|
||||
# Iterate through classes in order of preference
|
||||
for class_name in bringtofront:
|
||||
|
||||
@@ -312,21 +312,28 @@ def select_cost_schedule_products(
|
||||
products = cost.get_cost_schedule_products(cost_schedule)
|
||||
spatial.select_products(products)
|
||||
|
||||
def import_cost_schedule_csv(cost: tool.Cost, file_path: str, is_schedule_of_rates: bool) -> ifcopenshell.entity_instance:
|
||||
|
||||
def import_cost_schedule_csv(
|
||||
cost: tool.Cost, file_path: str, is_schedule_of_rates: bool
|
||||
) -> ifcopenshell.entity_instance:
|
||||
cost_schedule = cost.import_cost_schedule_csv(file_path, is_schedule_of_rates)
|
||||
return cost_schedule
|
||||
|
||||
|
||||
def add_csv_filepath(cost: tool.Cost, file_path: str, is_schedule_of_rates: bool, cost_schedule) -> None:
|
||||
cost.add_csv_filepath(file_path, is_schedule_of_rates, cost_schedule)
|
||||
|
||||
|
||||
def remove_csv_filepath(cost: tool.Cost, cost_schedule) -> None:
|
||||
cost.remove_csv_filepath(cost_schedule)
|
||||
|
||||
def refresh_cost_schedule_csv(ifc: tool.Ifc, cost:tool.Cost) -> None:
|
||||
|
||||
def refresh_cost_schedule_csv(ifc: tool.Ifc, cost: tool.Cost) -> None:
|
||||
cost.delete_all_cost_items()
|
||||
cost.refresh_cost_schedule_csv()
|
||||
cost.load_cost_schedule_tree()
|
||||
|
||||
|
||||
def add_cost_column(cost: tool.Cost, name: str) -> None:
|
||||
cost.add_cost_column(name)
|
||||
|
||||
|
||||
@@ -318,8 +318,8 @@ def duplicate_drawing(
|
||||
for new_elements in old_to_new.values():
|
||||
# Remove the Blender object, since we haven't actually activated the duplicated drawing
|
||||
for new_element in new_elements:
|
||||
print('new element', new_element)
|
||||
print('gonna remove', ifc.get_object(new_element))
|
||||
print("new element", new_element)
|
||||
print("gonna remove", ifc.get_object(new_element))
|
||||
blender.remove_object(ifc.get_object(new_element))
|
||||
new_annotations.extend(new_elements)
|
||||
new_annotation = set(new_annotations)
|
||||
|
||||
@@ -561,7 +561,9 @@ class Cost(bonsai.core.tool.Cost):
|
||||
return products
|
||||
|
||||
@classmethod
|
||||
def import_cost_schedule_csv(cls, file_path: Optional[str] = None, is_schedule_of_rates: bool = False) -> ifcopenshell.entity_instance:
|
||||
def import_cost_schedule_csv(
|
||||
cls, file_path: Optional[str] = None, is_schedule_of_rates: bool = False
|
||||
) -> ifcopenshell.entity_instance:
|
||||
if not file_path:
|
||||
return
|
||||
from ifc5d.csv2ifc import Csv2Ifc
|
||||
@@ -572,12 +574,17 @@ class Cost(bonsai.core.tool.Cost):
|
||||
csv2ifc.execute()
|
||||
print("Import finished in {:.2f} seconds".format(time.time() - start))
|
||||
return csv2ifc.cost_schedule
|
||||
|
||||
|
||||
@classmethod
|
||||
def add_csv_filepath(cls, file_path: Optional[str] = None, is_schedule_of_rates: bool = False, cost_schedule: ifcopenshell.entity_instance = None) -> None:
|
||||
def add_csv_filepath(
|
||||
cls,
|
||||
file_path: Optional[str] = None,
|
||||
is_schedule_of_rates: bool = False,
|
||||
cost_schedule: ifcopenshell.entity_instance = None,
|
||||
) -> None:
|
||||
if not file_path:
|
||||
return
|
||||
|
||||
|
||||
props = cls.get_cost_props()
|
||||
if not props.active_cost_schedule_id in [item.cost_item_id for item in props.cost_schedule_files]:
|
||||
item = props.cost_schedule_files.add()
|
||||
@@ -585,12 +592,12 @@ class Cost(bonsai.core.tool.Cost):
|
||||
item.csv_filepath = file_path
|
||||
else:
|
||||
return
|
||||
|
||||
|
||||
@classmethod
|
||||
def remove_csv_filepath(cls, cost_schedule: ifcopenshell.entity_instance = None) -> None:
|
||||
if not cost_schedule:
|
||||
return
|
||||
|
||||
|
||||
props = cls.get_cost_props()
|
||||
cost_schedule_id = cost_schedule.id()
|
||||
if cost_schedule_id in [item.cost_item_id for item in props.cost_schedule_files]:
|
||||
@@ -601,28 +608,30 @@ class Cost(bonsai.core.tool.Cost):
|
||||
return
|
||||
else:
|
||||
return
|
||||
|
||||
|
||||
@classmethod
|
||||
def delete_all_cost_items(cls):
|
||||
cost_schedule = tool.Cost.get_active_cost_schedule()
|
||||
items = ifcopenshell.util.cost.get_root_cost_items(cost_schedule)
|
||||
for item in items:
|
||||
cost_item_id = item.id()
|
||||
ifcopenshell.api.run("cost.remove_cost_item", tool.Ifc.get(), cost_item = item)
|
||||
ifcopenshell.api.run("cost.remove_cost_item", tool.Ifc.get(), cost_item=item)
|
||||
tool.Cost.clean_up_cost_item_tree(cost_item_id)
|
||||
|
||||
|
||||
@classmethod
|
||||
def refresh_cost_schedule_csv(cls):
|
||||
from ifc5d.csv2ifc import Csv2Ifc
|
||||
|
||||
props = cls.get_cost_props()
|
||||
cost_schedule_id = props.active_cost_schedule_id
|
||||
file_path = next((item.csv_filepath for item in props.cost_schedule_files if item.cost_item_id == cost_schedule_id), None)
|
||||
file_path = next(
|
||||
(item.csv_filepath for item in props.cost_schedule_files if item.cost_item_id == cost_schedule_id), None
|
||||
)
|
||||
if not file_path:
|
||||
return
|
||||
|
||||
|
||||
cost_schedule = tool.Ifc.get_entity_by_id(cost_schedule_id)
|
||||
|
||||
|
||||
csv2ifc = Csv2Ifc()
|
||||
csv2ifc.csv = file_path
|
||||
csv2ifc.file = tool.Ifc.get()
|
||||
@@ -631,7 +640,7 @@ class Cost(bonsai.core.tool.Cost):
|
||||
csv2ifc.refresh()
|
||||
|
||||
print("Csv file correctly refreshed")
|
||||
|
||||
|
||||
@classmethod
|
||||
def add_cost_column(cls, name: str) -> None:
|
||||
props = cls.get_cost_props()
|
||||
|
||||
@@ -152,7 +152,9 @@ class Drawer:
|
||||
# self.svg_settings.set_deflection_tolerance(0.0001)
|
||||
self.svg_buffer = ifcopenshell.geom.serializers.buffer()
|
||||
self.serialiser_settings = ifcopenshell.geom.serializer_settings()
|
||||
self.serialiser = ifcopenshell.geom.serializers.svg(self.svg_buffer, self.svg_settings, self.serialiser_settings)
|
||||
self.serialiser = ifcopenshell.geom.serializers.svg(
|
||||
self.svg_buffer, self.svg_settings, self.serialiser_settings
|
||||
)
|
||||
self.serialiser.setFile(ifc)
|
||||
self.serialiser.setWithoutStoreys(True)
|
||||
self.serialiser.setPolygonal(True)
|
||||
|
||||
Reference in New Issue
Block a user