From 7eac5397cdf4dd32ed5b3a6eb22b2ea727befded Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Wed, 6 Jul 2022 18:29:22 +1000 Subject: [PATCH] Run black --- .../blenderbim/bim/module/brick/prop.py | 2 +- .../blenderbim/bim/module/debug/operator.py | 1 + .../blenderbim/bim/module/drawing/operator.py | 4 +- .../blenderbim/bim/module/drawing/prop.py | 1 + .../blenderbim/bim/module/drawing/sheeter.py | 2 +- .../bim/module/drawing/svgwriter.py | 46 +++++++++++---- .../bim/module/geometry/operator.py | 5 +- .../blenderbim/bim/module/material/data.py | 4 +- .../blenderbim/bim/module/material/prop.py | 4 +- .../blenderbim/bim/module/model/mep.py | 12 ++-- .../blenderbim/bim/module/model/product.py | 4 +- .../blenderbim/bim/module/owner/data.py | 11 ++-- .../blenderbim/bim/module/project/operator.py | 2 +- .../bim/module/pset_template/operator.py | 57 ++++++++++--------- .../bim/module/pset_template/prop.py | 7 +-- .../blenderbim/bim/module/pset_template/ui.py | 29 +++++----- .../bim/module/sequence/operator.py | 1 + .../blenderbim/bim/module/style/ui.py | 2 +- .../blenderbim/bim/module/unit/data.py | 2 +- src/blenderbim/blenderbim/bim/operator.py | 2 +- src/blenderbim/blenderbim/bim/prop.py | 1 + src/blenderbim/blenderbim/tool/drawing.py | 8 +-- src/blenderbim/blenderbim/tool/material.py | 4 +- src/blenderbim/test/core/test_system.py | 1 - src/blenderbim/test/tool/test_georeference.py | 33 +++++------ 25 files changed, 134 insertions(+), 111 deletions(-) diff --git a/src/blenderbim/blenderbim/bim/module/brick/prop.py b/src/blenderbim/blenderbim/bim/module/brick/prop.py index 0d4eec7a6d..8d523b68df 100644 --- a/src/blenderbim/blenderbim/bim/module/brick/prop.py +++ b/src/blenderbim/blenderbim/bim/module/brick/prop.py @@ -69,7 +69,7 @@ class BIMBrickProperties(PropertyGroup): libraries: EnumProperty(name="Libraries", items=get_libraries) namespace: EnumProperty(name="Namespace", items=get_namespaces) brick_equipment_class: EnumProperty(name="Brick Equipment Class", items=get_brick_equipment_classes) - + getter_enum = { "libraries": get_libraries, "namespace": get_namespaces, diff --git a/src/blenderbim/blenderbim/bim/module/debug/operator.py b/src/blenderbim/blenderbim/bim/module/debug/operator.py index bdf852b568..5d723020ea 100644 --- a/src/blenderbim/blenderbim/bim/module/debug/operator.py +++ b/src/blenderbim/blenderbim/bim/module/debug/operator.py @@ -112,6 +112,7 @@ class CreateAllShapes(bpy.types.Operator): def execute(self, context): self.file = IfcStore.get_file() elements = self.file.by_type("IfcElement") + self.file.by_type("IfcSpace") + total = len(elements) settings = ifcopenshell.geom.settings() failures = [] diff --git a/src/blenderbim/blenderbim/bim/module/drawing/operator.py b/src/blenderbim/blenderbim/bim/module/drawing/operator.py index 7dc4ab2428..eca88ec09d 100644 --- a/src/blenderbim/blenderbim/bim/module/drawing/operator.py +++ b/src/blenderbim/blenderbim/bim/module/drawing/operator.py @@ -152,13 +152,13 @@ class CreateDrawing(bpy.types.Operator): with profile("Generate underlay"): underlay_svg = self.generate_underlay(context) - + with profile("Generate linework"): linework_svg = self.generate_linework(context) with profile("Generate annotation"): annotation_svg = self.generate_annotation(context) - + with profile("Combine SVG layers"): svg_path = self.combine_svgs(context, underlay_svg, linework_svg, annotation_svg) diff --git a/src/blenderbim/blenderbim/bim/module/drawing/prop.py b/src/blenderbim/blenderbim/bim/module/drawing/prop.py index 2016f23dd2..b20f871d11 100644 --- a/src/blenderbim/blenderbim/bim/module/drawing/prop.py +++ b/src/blenderbim/blenderbim/bim/module/drawing/prop.py @@ -392,6 +392,7 @@ class BIMTextProperties(PropertyGroup): name="Font Size", ) + class BIMAssignedProductProperties(PropertyGroup): is_editing_product: BoolProperty(name="Is Editing Product", default=False) relating_product: PointerProperty(name="Relating Product", type=bpy.types.Object) diff --git a/src/blenderbim/blenderbim/bim/module/drawing/sheeter.py b/src/blenderbim/blenderbim/bim/module/drawing/sheeter.py index 7855e6067c..4df0f4e9f9 100644 --- a/src/blenderbim/blenderbim/bim/module/drawing/sheeter.py +++ b/src/blenderbim/blenderbim/bim/module/drawing/sheeter.py @@ -118,7 +118,7 @@ class SheetBuilder: sheet_tree = ET.parse(sheet_path) sheet_root = sheet_tree.getroot() - for g in sheet_root.findall('{http://www.w3.org/2000/svg}g'): + for g in sheet_root.findall("{http://www.w3.org/2000/svg}g"): if g.attrib.get("data-id") == str(reference.id()): sheet_root.remove(g) break diff --git a/src/blenderbim/blenderbim/bim/module/drawing/svgwriter.py b/src/blenderbim/blenderbim/bim/module/drawing/svgwriter.py index 891b8f2092..74b3b06642 100644 --- a/src/blenderbim/blenderbim/bim/module/drawing/svgwriter.py +++ b/src/blenderbim/blenderbim/bim/module/drawing/svgwriter.py @@ -70,7 +70,7 @@ class SvgWriter: viewBox=("0 0 {} {}".format(self.width, self.height)), id="root", data_scale=self.human_scale, - debug=False, # Disable validation so that we can insert the IFC namespace + debug=False, # Disable validation so that we can insert the IFC namespace ) self.svg.attribs["xmlns:ifc"] = "http://www.ifcopenshell.org/ns" return self @@ -81,7 +81,9 @@ class SvgWriter: def draw_underlay(self, image): self.svg.add( self.svg.image( - os.path.join("..", "diagrams", os.path.basename(image)), width=self.width, height=self.height, + os.path.join("..", "diagrams", os.path.basename(image)), + width=self.width, + height=self.height, ) ) return self @@ -252,7 +254,9 @@ class SvgWriter: end = Vector(((x_offset + v1.x), (y_offset - v1.y))) vector = end - start line = self.svg.add( - self.svg.line(start=tuple(start * self.svg_scale), end=tuple(end * self.svg_scale), class_=" ".join(classes)) + self.svg.line( + start=tuple(start * self.svg_scale), end=tuple(end * self.svg_scale), class_=" ".join(classes) + ) ) line["stroke-dasharray"] = "12.5, 3, 3, 3" axis_tag = tool.Ifc.get_entity(obj).Name @@ -361,7 +365,9 @@ class SvgWriter: end = Vector(((x_offset + v1.x), (y_offset - v1.y))) vector = end - start line = self.svg.add( - self.svg.line(start=tuple(start * self.svg_scale), end=tuple(end * self.svg_scale), class_=" ".join(classes)) + self.svg.line( + start=tuple(start * self.svg_scale), end=tuple(end * self.svg_scale), class_=" ".join(classes) + ) ) def draw_leader_annotation(self, obj): @@ -427,7 +433,9 @@ class SvgWriter: (symbol_position * self.svg_scale)[1], ) - self.svg.add(self.svg.use("#elevation-arrow", insert=tuple(symbol_position * self.svg_scale), transform=transform)) + self.svg.add( + self.svg.use("#elevation-arrow", insert=tuple(symbol_position * self.svg_scale), transform=transform) + ) self.svg.add(self.svg.use("#elevation-tag", insert=tuple(symbol_position * self.svg_scale))) reference_id, sheet_id = self.get_reference_and_sheet_id_from_annotation(tool.Ifc.get_entity(obj)) @@ -666,7 +674,7 @@ class SvgWriter: dir2 = ((arc_matrix.inverted() @ arc_end_pts[1]) - (arc_matrix.inverted() @ center)).normalized() angle = -dir1.xy.angle_signed(dir2.xy) - #if is_reflex: + # if is_reflex: # angle = angle % (math.pi * 2) # Center of gravity of all vertices, used to help position the text @@ -680,7 +688,9 @@ class SvgWriter: arc_midpoint = center + ((cog - center).normalized() * radius) text_position = self.project_point_onto_camera(arc_midpoint) - text_position = Vector(((x_offset + text_position.x) * self.svg_scale, (y_offset - text_position.y) * self.svg_scale)) + text_position = Vector( + ((x_offset + text_position.x) * self.svg_scale, (y_offset - text_position.y) * self.svg_scale) + ) center_projected = self.project_point_onto_camera(center) center_position = Vector( @@ -704,8 +714,12 @@ class SvgWriter: # Draw SVG arc, see for details: http://xahlee.info/js/svg_circle_arc.html arc_proj_end_pts = [self.project_point_onto_camera(v) for v in arc_end_pts] - p1 = Vector(((x_offset + arc_proj_end_pts[0].x) * self.svg_scale, (y_offset - arc_proj_end_pts[0].y) * self.svg_scale)) - p2 = Vector(((x_offset + arc_proj_end_pts[1].x) * self.svg_scale, (y_offset - arc_proj_end_pts[1].y) * self.svg_scale)) + p1 = Vector( + ((x_offset + arc_proj_end_pts[0].x) * self.svg_scale, (y_offset - arc_proj_end_pts[0].y) * self.svg_scale) + ) + p2 = Vector( + ((x_offset + arc_proj_end_pts[1].x) * self.svg_scale, (y_offset - arc_proj_end_pts[1].y) * self.svg_scale) + ) r = radius * self.svg_scale # reflex = 1 if angle > math.pi else 0 reflex = is_reflex @@ -735,10 +749,16 @@ class SvgWriter: path = self.svg.add(self.svg.path(d=d, class_=" ".join(classes))) p0 = Vector( - ((x_offset + projected_points[0].x) * self.svg_scale, (y_offset - projected_points[0].y) * self.svg_scale) + ( + (x_offset + projected_points[0].x) * self.svg_scale, + (y_offset - projected_points[0].y) * self.svg_scale, + ) ) p1 = Vector( - ((x_offset + projected_points[1].x) * self.svg_scale, (y_offset - projected_points[1].y) * self.svg_scale) + ( + (x_offset + projected_points[1].x) * self.svg_scale, + (y_offset - projected_points[1].y) * self.svg_scale, + ) ) text_offset = (p0 - p1).xy.normalized() * 5 text_position = projected_points[0] @@ -823,7 +843,9 @@ class SvgWriter: text_position = (mid * self.svg_scale) + perpendicular rotation = math.degrees(vector.angle_signed(Vector((1, 0)))) line = self.svg.add( - self.svg.line(start=tuple(start * self.svg_scale), end=tuple(end * self.svg_scale), class_=" ".join(classes)) + self.svg.line( + start=tuple(start * self.svg_scale), end=tuple(end * self.svg_scale), class_=" ".join(classes) + ) ) if text_override is not None: text = text_override diff --git a/src/blenderbim/blenderbim/bim/module/geometry/operator.py b/src/blenderbim/blenderbim/bim/module/geometry/operator.py index 541cb0a92d..81b78dd4a2 100644 --- a/src/blenderbim/blenderbim/bim/module/geometry/operator.py +++ b/src/blenderbim/blenderbim/bim/module/geometry/operator.py @@ -207,7 +207,10 @@ class UpdateRepresentation(bpy.types.Operator): new_representation = ifcopenshell.api.run("geometry.add_representation", self.file, **representation_data) if tool.Geometry.is_body_representation(new_representation): - [tool.Geometry.run_style_add_style(obj=mat) for mat in tool.Geometry.get_object_materials_without_styles(obj)] + [ + tool.Geometry.run_style_add_style(obj=mat) + for mat in tool.Geometry.get_object_materials_without_styles(obj) + ] ifcopenshell.api.run( "style.assign_representation_styles", self.file, diff --git a/src/blenderbim/blenderbim/bim/module/material/data.py b/src/blenderbim/blenderbim/bim/module/material/data.py index 4d90a29408..78ef924562 100644 --- a/src/blenderbim/blenderbim/bim/module/material/data.py +++ b/src/blenderbim/blenderbim/bim/module/material/data.py @@ -84,7 +84,9 @@ class ObjectMaterialData: @classmethod def materials(cls): - return sorted([(str(m.id()), m.Name or "Unnamed", "") for m in tool.Ifc.get().by_type("IfcMaterial")], key=lambda x: x[1]) + return sorted( + [(str(m.id()), m.Name or "Unnamed", "") for m in tool.Ifc.get().by_type("IfcMaterial")], key=lambda x: x[1] + ) @classmethod def type_material(cls): diff --git a/src/blenderbim/blenderbim/bim/module/material/prop.py b/src/blenderbim/blenderbim/bim/module/material/prop.py index 88b85fa0ee..1795156ebe 100644 --- a/src/blenderbim/blenderbim/bim/module/material/prop.py +++ b/src/blenderbim/blenderbim/bim/module/material/prop.py @@ -138,6 +138,4 @@ class BIMObjectMaterialProperties(PropertyGroup): items=getParameterizedProfileClasses, name="Parameterized Profile Classes" ) - getter_enum = { - "material": get_materials - } + getter_enum = {"material": get_materials} diff --git a/src/blenderbim/blenderbim/bim/module/model/mep.py b/src/blenderbim/blenderbim/bim/module/model/mep.py index 3fe07c3fe8..e8b02b97e6 100644 --- a/src/blenderbim/blenderbim/bim/module/model/mep.py +++ b/src/blenderbim/blenderbim/bim/module/model/mep.py @@ -65,14 +65,14 @@ class MepGenerator: def create_rectangle_segment(self): verts = [ - Vector((- self.width / 2, self.height / 2, 0)), - Vector((- self.width / 2, - self.height / 2, 0)), - Vector((- self.width / 2, self.height / 2, self.length)), - Vector((- self.width / 2, - self.height / 2, self.length)), + Vector((-self.width / 2, self.height / 2, 0)), + Vector((-self.width / 2, -self.height / 2, 0)), + Vector((-self.width / 2, self.height / 2, self.length)), + Vector((-self.width / 2, -self.height / 2, self.length)), Vector((self.width / 2, self.height / 2, 0)), - Vector((self.width / 2, - self.height / 2, 0)), + Vector((self.width / 2, -self.height / 2, 0)), Vector((self.width / 2, self.height / 2, self.length)), - Vector((self.width / 2, - self.height / 2, self.length)), + Vector((self.width / 2, -self.height / 2, self.length)), ] faces = [ [1, 3, 2, 0], diff --git a/src/blenderbim/blenderbim/bim/module/model/product.py b/src/blenderbim/blenderbim/bim/module/model/product.py index b56712216d..6a383c6d41 100644 --- a/src/blenderbim/blenderbim/bim/module/model/product.py +++ b/src/blenderbim/blenderbim/bim/module/model/product.py @@ -120,9 +120,7 @@ class AddTypeInstance(bpy.types.Operator): collection_obj = bpy.data.objects.get(collection.name) bpy.ops.bim.assign_class(obj=obj.name, ifc_class=instance_class) element = tool.Ifc.get_entity(obj) - blenderbim.core.type.assign_type( - tool.Ifc, tool.Type, element=element, type=relating_type - ) + blenderbim.core.type.assign_type(tool.Ifc, tool.Type, element=element, type=relating_type) if building_obj: if instance_class in ["IfcWindow", "IfcDoor"]: diff --git a/src/blenderbim/blenderbim/bim/module/owner/data.py b/src/blenderbim/blenderbim/bim/module/owner/data.py index be1cae0192..068bf74164 100644 --- a/src/blenderbim/blenderbim/bim/module/owner/data.py +++ b/src/blenderbim/blenderbim/bim/module/owner/data.py @@ -253,10 +253,7 @@ class ObjectActorData: @classmethod def load(cls): cls.is_loaded = True - cls.data = { - "actor": cls.actor(), - "actors": cls.actors() - } + cls.data = {"actor": cls.actor(), "actors": cls.actors()} @classmethod def actor(cls): @@ -279,9 +276,9 @@ class ObjectActorData: roles = cls.get_roles(actor.TheActor.ThePerson) roles.extend(cls.get_roles(actor.TheActor.TheOrganization)) role = ", ".join(roles) - results.append({ - "id": actor.id(), "name": actor.Name or "Unnamed", "role": role, "ifc_class": actor.is_a() - }) + results.append( + {"id": actor.id(), "name": actor.Name or "Unnamed", "role": role, "ifc_class": actor.is_a()} + ) return results @classmethod diff --git a/src/blenderbim/blenderbim/bim/module/project/operator.py b/src/blenderbim/blenderbim/bim/module/project/operator.py index f311ff50d5..dc2539db54 100644 --- a/src/blenderbim/blenderbim/bim/module/project/operator.py +++ b/src/blenderbim/blenderbim/bim/module/project/operator.py @@ -732,7 +732,7 @@ class ToggleLinkVisibility(bpy.types.Operator): def toggle_wireframe(self, link): objs = filter(lambda obj: "IfcOpeningElement" not in obj.name, link.collection.all_objects) - for i,obj in enumerate(objs): + for i, obj in enumerate(objs): if i == 0: if obj.display_type == "WIRE": display_type = "TEXTURED" diff --git a/src/blenderbim/blenderbim/bim/module/pset_template/operator.py b/src/blenderbim/blenderbim/bim/module/pset_template/operator.py index 9013a6901f..c01aefe847 100644 --- a/src/blenderbim/blenderbim/bim/module/pset_template/operator.py +++ b/src/blenderbim/blenderbim/bim/module/pset_template/operator.py @@ -28,31 +28,31 @@ from ifcopenshell.api.pset_template.data import Data from blenderbim.bim.ifc import IfcStore -#This is just a temporary operator until -#@Moult performs some of his refactor-magic ;) - vulevukusej +# This is just a temporary operator until +# @Moult performs some of his refactor-magic ;) - vulevukusej class RefreshPsetTemplates(bpy.types.Operator): bl_idname = "bim.refresh_psettemplates" bl_label = "Refresh the data for PsetTemplates" bl_options = {"REGISTER", "UNDO"} - + def execute(self, context): purge_templates() - purge_psets() - return {"FINISHED"} - - + purge_psets() + return {"FINISHED"} + + class AddPsetFile(bpy.types.Operator): bl_idname = "bim.add_pset_file" bl_label = "Add Pset File" bl_options = {"REGISTER", "UNDO"} - + def invoke(self, context, event): return context.window_manager.invoke_props_dialog(self, width=250) - + def draw(self, context): self.props = context.scene.BIMPsetTemplateProperties self.layout.prop(self.props, "new_template_filename", text="Filename:") - + def execute(self, context): template = ifcopenshell.file() filepath = os.path.join( @@ -60,7 +60,7 @@ class AddPsetFile(bpy.types.Operator): "pset", self.props.new_template_filename + ".ifc", ) - + template.create_entity( "IFCPROPERTYSETTEMPLATE", **{ @@ -68,14 +68,14 @@ class AddPsetFile(bpy.types.Operator): "Name": "Name", "Description": "Description", "TemplateType": "PSET_TYPEDRIVENONLY", - "ApplicableEntity": "IfcTypeObject" + "ApplicableEntity": "IfcTypeObject", } ) template.write(filepath) self.props.new_template_filename = "" return {"FINISHED"} - - + + class AddPsetTemplate(bpy.types.Operator): bl_idname = "bim.add_pset_template" bl_label = "Add Pset Template" @@ -190,33 +190,35 @@ class EnableEditingPropTemplate(bpy.types.Operator): props.active_prop_template.primary_measure_type = template["PrimaryMeasureType"] props.active_prop_template.template_type = template["TemplateType"] props.active_prop_template.enum_values.clear() - + if template["Enumerators"]: props.active_prop_template.enum_values.clear() data_type = props.active_prop_template.get_value_name() for e in template["Enumerators"].EnumerationValues: new = props.active_prop_template.enum_values.add() setattr(new, data_type, e.wrappedValue) - + return {"FINISHED"} - + + class DeletePropEnum(bpy.types.Operator): bl_idname = "bim.delete_prop_enum" bl_label = "delete property enumeration" bl_options = {"REGISTER", "UNDO"} index: bpy.props.IntProperty() - + def execute(self, context): active_prop = context.scene.BIMPsetTemplateProperties.active_prop_template active_prop.enum_values.remove(self.index) return {"FINISHED"} + class AddPropEnum(bpy.types.Operator): bl_idname = "bim.add_prop_enum" bl_label = "add property enumeration" bl_options = {"REGISTER", "UNDO"} index: bpy.props.IntProperty() - + def execute(self, context): active_prop = context.scene.BIMPsetTemplateProperties.active_prop_template active_prop.enum_values.add() @@ -380,26 +382,27 @@ class EditPropTemplate(bpy.types.Operator): "Description": props.active_prop_template.description, "PrimaryMeasureType": props.active_prop_template.primary_measure_type, "TemplateType": props.active_prop_template.template_type, - "Enumerators": enumerator + "Enumerators": enumerator, }, } ) Data.load(IfcStore.pset_template_file) bpy.ops.bim.disable_editing_prop_template() return {"FINISHED"} - - #TODO -This will need to go into the + + # TODO -This will need to go into the # api code at some point - vulevukusej def generate_prop_enum(self, props): self.file = IfcStore.pset_template_file data_type = props.active_prop_template.get_value_name() prop = props.active_prop_template prop_enum = self.file.create_entity( - "IFCPROPERTYENUMERATION", - Name=prop.name, - EnumerationValues=tuple(self.file.create_entity( - prop.primary_measure_type, ev[data_type]) for ev in prop.enum_values) - ) + "IFCPROPERTYENUMERATION", + Name=prop.name, + EnumerationValues=tuple( + self.file.create_entity(prop.primary_measure_type, ev[data_type]) for ev in prop.enum_values + ), + ) return prop_enum def rollback(self, data): diff --git a/src/blenderbim/blenderbim/bim/module/pset_template/prop.py b/src/blenderbim/blenderbim/bim/module/pset_template/prop.py index 94acb6c234..62a6bcf474 100644 --- a/src/blenderbim/blenderbim/bim/module/pset_template/prop.py +++ b/src/blenderbim/blenderbim/bim/module/pset_template/prop.py @@ -164,11 +164,8 @@ class PropTemplate(PropertyGroup): description: StringProperty(name="Description") primary_measure_type: EnumProperty(items=get_primary_measure_type, name="Primary Measure Type") template_type: EnumProperty( - items=[ - ("P_SINGLEVALUE","P_SINGLEVALUE",""), - ("P_ENUMERATEDVALUE","P_ENUMERATEDVALUE","") - ], - name="Template Type" + items=[("P_SINGLEVALUE", "P_SINGLEVALUE", ""), ("P_ENUMERATEDVALUE", "P_ENUMERATEDVALUE", "")], + name="Template Type", ) enum_values: CollectionProperty(type=EnumerationValues) getter_enum = { diff --git a/src/blenderbim/blenderbim/bim/module/pset_template/ui.py b/src/blenderbim/blenderbim/bim/module/pset_template/ui.py index 1c914f83d3..4fa0b67644 100644 --- a/src/blenderbim/blenderbim/bim/module/pset_template/ui.py +++ b/src/blenderbim/blenderbim/bim/module/pset_template/ui.py @@ -38,13 +38,13 @@ class BIM_PT_pset_template(Panel): def draw(self, context): layout = self.layout props = context.scene.BIMPsetTemplateProperties - + row = layout.row(align=True) prop_with_search(row, props, "pset_template_files", text="") row.operator("bim.save_pset_template_file", text="", icon="EXPORT") - row.operator("bim.add_pset_file",icon="ADD",text="") + row.operator("bim.add_pset_file", icon="ADD", text="") row.operator("bim.refresh_psettemplates", icon="FILE_REFRESH", text="") - + row = layout.row(align=True) if bool(getPsetTemplates(props, context)): @@ -75,7 +75,7 @@ class BIM_PT_pset_template(Panel): prop_with_search(layout, props.active_pset_template, "template_type") row = layout.row() row.prop(props.active_pset_template, "applicable_entity") - else: + else: pset_template = Data.pset_templates[int(props.pset_templates)] for name, value in pset_template.items(): if name == "id" or name == "type" or name == "HasPropertyTemplates": @@ -87,7 +87,7 @@ class BIM_PT_pset_template(Panel): row = layout.row(align=True) row.label(text="Property Templates", icon="COPY_ID") row.operator("bim.add_prop_template", icon="ADD", text="") - + row = layout.row() row.label(text="Name | Description | PrimaryMeasureType | TemplateType") @@ -100,26 +100,27 @@ class BIM_PT_pset_template(Panel): row.prop(props.active_prop_template, "description", text="") prop_with_search(row, props.active_prop_template, "primary_measure_type", text="") row.prop(props.active_prop_template, "template_type", text="") - + if props.active_prop_template.template_type == "P_ENUMERATEDVALUE": row = layout.row(align=True) split = row.split(factor=0.2) - c=split.column() - c.label(text="Enumerations:",) - - c=split.column() + c = split.column() + c.label( + text="Enumerations:", + ) + + c = split.column() box = c.box() grid = box.column_flow(columns=4) value_name = props.active_prop_template.get_value_name() r = grid.row() r.operator("bim.add_prop_enum", text="Add Enum") - for k,v in enumerate(props.active_prop_template.enum_values): - r = grid.row(align=True) + for k, v in enumerate(props.active_prop_template.enum_values): + r = grid.row(align=True) r.prop(v, value_name, text="") op = r.operator("bim.delete_prop_enum", icon="X", text="") op.index = k - - + else: row.label(text=prop_template["Name"]) row.label(text=prop_template["Description"]) diff --git a/src/blenderbim/blenderbim/bim/module/sequence/operator.py b/src/blenderbim/blenderbim/bim/module/sequence/operator.py index d7082cfa9e..cd67c76fc3 100644 --- a/src/blenderbim/blenderbim/bim/module/sequence/operator.py +++ b/src/blenderbim/blenderbim/bim/module/sequence/operator.py @@ -624,6 +624,7 @@ class EditTaskTime(bpy.types.Operator): if prop.is_null: attributes[prop.name] = None return True + # TODO make this parse PT32 as P4D attributes[prop.name] = helper.parse_duration(prop.string_value) return True diff --git a/src/blenderbim/blenderbim/bim/module/style/ui.py b/src/blenderbim/blenderbim/bim/module/style/ui.py index 86f4261866..b5a0cfe586 100644 --- a/src/blenderbim/blenderbim/bim/module/style/ui.py +++ b/src/blenderbim/blenderbim/bim/module/style/ui.py @@ -54,7 +54,7 @@ class BIM_PT_styles(Panel): row = self.layout.row(align=True) row.alignment = "RIGHT" - #row.operator("bim.add_presentation_style", text="", icon="ADD") + # row.operator("bim.add_presentation_style", text="", icon="ADD") if self.props.styles and self.props.active_style_index < len(self.props.styles): style = self.props.styles[self.props.active_style_index] op = row.operator("bim.select_by_style", text="", icon="RESTRICT_SELECT_OFF") diff --git a/src/blenderbim/blenderbim/bim/module/unit/data.py b/src/blenderbim/blenderbim/bim/module/unit/data.py index 971e57b03a..9fa647e08c 100644 --- a/src/blenderbim/blenderbim/bim/module/unit/data.py +++ b/src/blenderbim/blenderbim/bim/module/unit/data.py @@ -37,7 +37,7 @@ class UnitsData: "unit_classes": cls.unit_classes(), "named_unit_types": cls.named_unit_types(), "conversion_unit_types": cls.conversion_unit_types(), - "total_units": cls.get_total_units() + "total_units": cls.get_total_units(), } cls.is_loaded = True diff --git a/src/blenderbim/blenderbim/bim/operator.py b/src/blenderbim/blenderbim/bim/operator.py index 17ec6ed626..91131d772f 100644 --- a/src/blenderbim/blenderbim/bim/operator.py +++ b/src/blenderbim/blenderbim/bim/operator.py @@ -560,5 +560,5 @@ class BIM_OT_enum_property_search(bpy.types.Operator): def draw(self, context): # Mandatory to access context.data in update : - self.layout.context_pointer_set(name="data", data=self.data) + self.layout.context_pointer_set(name="data", data=self.data) self.layout.prop_search(self, "dummy_name", self, "collection_name") diff --git a/src/blenderbim/blenderbim/bim/prop.py b/src/blenderbim/blenderbim/bim/prop.py index 50817c4487..ffdfc8bb27 100644 --- a/src/blenderbim/blenderbim/bim/prop.py +++ b/src/blenderbim/blenderbim/bim/prop.py @@ -195,6 +195,7 @@ class Attribute(PropertyGroup): is_null: BoolProperty(name="Is Null") is_optional: BoolProperty(name="Is Optional") is_uri: BoolProperty(name="Is Uri", default=False) + is_selected: BoolProperty(name="Is Selected", default=False) def get_value(self): if self.is_null: diff --git a/src/blenderbim/blenderbim/tool/drawing.py b/src/blenderbim/blenderbim/tool/drawing.py index 34d9a153bf..62388b23b7 100644 --- a/src/blenderbim/blenderbim/tool/drawing.py +++ b/src/blenderbim/blenderbim/tool/drawing.py @@ -375,15 +375,11 @@ class Drawing(blenderbim.core.tool.Drawing): @classmethod def open_spreadsheet(cls, uri): - cls.open_with_user_command( - bpy.context.preferences.addons["blenderbim"].preferences.spreadsheet_command, uri - ) + cls.open_with_user_command(bpy.context.preferences.addons["blenderbim"].preferences.spreadsheet_command, uri) @classmethod def open_svg(cls, uri): - cls.open_with_user_command( - bpy.context.preferences.addons["blenderbim"].preferences.svg_command, uri - ) + cls.open_with_user_command(bpy.context.preferences.addons["blenderbim"].preferences.svg_command, uri) @classmethod def run_root_assign_class( diff --git a/src/blenderbim/blenderbim/tool/material.py b/src/blenderbim/blenderbim/tool/material.py index 0b3832ca24..42d70eb35d 100644 --- a/src/blenderbim/blenderbim/tool/material.py +++ b/src/blenderbim/blenderbim/tool/material.py @@ -75,7 +75,9 @@ class Material(blenderbim.core.tool.Material): new = props.materials.add() new.ifc_definition_id = material.id() new.name = get_name(material) - new.total_elements = len(ifcopenshell.util.element.get_elements_by_material(tool.Ifc.get(), material)) + new.total_elements = len( + ifcopenshell.util.element.get_elements_by_material(tool.Ifc.get(), material) + ) return for material in materials: new = props.materials.add() diff --git a/src/blenderbim/test/core/test_system.py b/src/blenderbim/test/core/test_system.py index 01c4171def..a27d0f90e5 100644 --- a/src/blenderbim/test/core/test_system.py +++ b/src/blenderbim/test/core/test_system.py @@ -125,7 +125,6 @@ class TestHidePorts: system.delete_element_objects(["port"]).should_be_called() subject.hide_ports(ifc, system, element="element") - def test_syncing_locations_if_objects_moved_prior_to_hiding_ports(self, ifc, system): ifc.get_object("element").should_be_called().will_return("obj") ifc.is_moved("obj").should_be_called().will_return(True) diff --git a/src/blenderbim/test/tool/test_georeference.py b/src/blenderbim/test/tool/test_georeference.py index 4dd8661e25..bddb670fbb 100644 --- a/src/blenderbim/test/tool/test_georeference.py +++ b/src/blenderbim/test/tool/test_georeference.py @@ -163,6 +163,7 @@ class TestGetMapConversionAttributes(NewFile): "Scale": 6.0, } + class TestGetTrueNorthAttributes(NewFile): def test_run(self): TestImportTrueNorth().test_run() @@ -185,18 +186,18 @@ class TestDisableEditing(NewFile): class TestSetCoordinates(NewFile): def test_run(self): - subject.set_coordinates("input", [1., 2., 3.]) + subject.set_coordinates("input", [1.0, 2.0, 3.0]) assert bpy.context.scene.BIMGeoreferenceProperties.coordinate_input == "1.0,2.0,3.0" - subject.set_coordinates("output", [4., 5., 6.]) + subject.set_coordinates("output", [4.0, 5.0, 6.0]) assert bpy.context.scene.BIMGeoreferenceProperties.coordinate_output == "4.0,5.0,6.0" class TestGetCoordinates(NewFile): def test_run(self): bpy.context.scene.BIMGeoreferenceProperties.coordinate_input = "1.0,2.0,3.0" - assert subject.get_coordinates("input") == [1., 2., 3.] + assert subject.get_coordinates("input") == [1.0, 2.0, 3.0] bpy.context.scene.BIMGeoreferenceProperties.coordinate_output = "4.0,5.0,6.0" - assert subject.get_coordinates("output") == [4., 5., 6.] + assert subject.get_coordinates("output") == [4.0, 5.0, 6.0] class TestGetCursorLocation(NewFile): @@ -207,8 +208,8 @@ class TestGetCursorLocation(NewFile): ifcopenshell.api.run("context.add_context", ifc, context_type="Model") unit = ifcopenshell.api.run("unit.add_si_unit", ifc, unit_type="LENGTHUNIT", prefix="MILLI", name="METRE") ifcopenshell.api.run("unit.assign_unit", ifc, units=[unit]) - bpy.context.scene.cursor.location = (1., 2., 3.) - assert subject.get_cursor_location() == [1000., 2000., 3000.] + bpy.context.scene.cursor.location = (1.0, 2.0, 3.0) + assert subject.get_cursor_location() == [1000.0, 2000.0, 3000.0] class TestSetCursorLocation(NewFile): @@ -219,8 +220,8 @@ class TestSetCursorLocation(NewFile): ifcopenshell.api.run("context.add_context", ifc, context_type="Model") unit = ifcopenshell.api.run("unit.add_si_unit", ifc, unit_type="LENGTHUNIT", prefix="MILLI", name="METRE") ifcopenshell.api.run("unit.assign_unit", ifc, units=[unit]) - subject.set_cursor_location([1000., 2000., 3000.]) - assert list(bpy.context.scene.cursor.location) == [1., 2., 3.] + subject.set_cursor_location([1000.0, 2000.0, 3000.0]) + assert list(bpy.context.scene.cursor.location) == [1.0, 2.0, 3.0] class TestSetIfcTrueNorth(NewFile): @@ -258,13 +259,13 @@ class TestGetMapConversion(NewFile): class TestXyz2Enh(NewFile): def test_run(self): - assert subject.xyz2enh([0., 0., 0.], None) == [0., 0., 0.] + assert subject.xyz2enh([0.0, 0.0, 0.0], None) == [0.0, 0.0, 0.0] def test_using_the_blender_offset(self): props = bpy.context.scene.BIMGeoreferenceProperties props.has_blender_offset = True props.blender_eastings = "1.0" - assert subject.xyz2enh([0., 0., 0.], None) == (1., 0., 0.) + assert subject.xyz2enh([0.0, 0.0, 0.0], None) == (1.0, 0.0, 0.0) def test_using_the_map_conversion(self): ifc = ifcopenshell.file() @@ -274,7 +275,7 @@ class TestXyz2Enh(NewFile): ifcopenshell.api.run("georeference.add_georeferencing", ifc) map_conversion = ifc.by_type("IfcMapConversion")[0] map_conversion.Eastings = 1.0 - assert subject.xyz2enh([0., 0., 0.], map_conversion) == (1., 0., 0.) + assert subject.xyz2enh([0.0, 0.0, 0.0], map_conversion) == (1.0, 0.0, 0.0) def test_applying_both_blender_offset_and_map_conversion(self): props = bpy.context.scene.BIMGeoreferenceProperties @@ -287,18 +288,18 @@ class TestXyz2Enh(NewFile): ifcopenshell.api.run("georeference.add_georeferencing", ifc) map_conversion = ifc.by_type("IfcMapConversion")[0] map_conversion.Northings = 1.0 - assert subject.xyz2enh([0., 0., 0.], map_conversion) == (1., 1., 0.) + assert subject.xyz2enh([0.0, 0.0, 0.0], map_conversion) == (1.0, 1.0, 0.0) class TestEnh2Xyz(NewFile): def test_run(self): - assert subject.enh2xyz([0., 0., 0.], None) == [0., 0., 0.] + assert subject.enh2xyz([0.0, 0.0, 0.0], None) == [0.0, 0.0, 0.0] def test_using_the_blender_offset(self): props = bpy.context.scene.BIMGeoreferenceProperties props.has_blender_offset = True props.blender_eastings = "1.0" - assert subject.enh2xyz([0., 0., 0.], None) == (-1., 0., 0.) + assert subject.enh2xyz([0.0, 0.0, 0.0], None) == (-1.0, 0.0, 0.0) def test_using_the_map_conversion(self): ifc = ifcopenshell.file() @@ -308,7 +309,7 @@ class TestEnh2Xyz(NewFile): ifcopenshell.api.run("georeference.add_georeferencing", ifc) map_conversion = ifc.by_type("IfcMapConversion")[0] map_conversion.Eastings = 1.0 - assert subject.enh2xyz([0., 0., 0.], map_conversion) == (-1., 0., 0.) + assert subject.enh2xyz([0.0, 0.0, 0.0], map_conversion) == (-1.0, 0.0, 0.0) def test_applying_both_blender_offset_and_map_conversion(self): props = bpy.context.scene.BIMGeoreferenceProperties @@ -321,7 +322,7 @@ class TestEnh2Xyz(NewFile): ifcopenshell.api.run("georeference.add_georeferencing", ifc) map_conversion = ifc.by_type("IfcMapConversion")[0] map_conversion.Northings = 1.0 - assert subject.enh2xyz([0., 0., 0.], map_conversion) == (-1., -1., 0.) + assert subject.enh2xyz([0.0, 0.0, 0.0], map_conversion) == (-1.0, -1.0, 0.0) class TestSetIfcGridNorth(NewFile):