diff --git a/src/blenderbim/blenderbim/bim/module/drawing/__init__.py b/src/blenderbim/blenderbim/bim/module/drawing/__init__.py index 403850fc51..8286edcba8 100644 --- a/src/blenderbim/blenderbim/bim/module/drawing/__init__.py +++ b/src/blenderbim/blenderbim/bim/module/drawing/__init__.py @@ -29,12 +29,10 @@ classes = ( operator.AddDrawingToSheet, operator.AddSchedule, operator.AddScheduleToSheet, - operator.AddSectionsAnnotations, operator.AddSheet, operator.BuildSchedule, operator.CleanWireframes, operator.ContractSheet, - operator.CopyGrid, operator.CreateDrawing, operator.CreateSheets, operator.DisableEditingAssignedProduct, diff --git a/src/blenderbim/blenderbim/bim/module/drawing/operator.py b/src/blenderbim/blenderbim/bim/module/drawing/operator.py index ac4491b13d..9144e5dca8 100644 --- a/src/blenderbim/blenderbim/bim/module/drawing/operator.py +++ b/src/blenderbim/blenderbim/bim/module/drawing/operator.py @@ -1195,170 +1195,6 @@ class CleanWireframes(bpy.types.Operator): return {"FINISHED"} -class CopyGrid(bpy.types.Operator): - bl_idname = "bim.add_grid" - bl_label = "Add Grid" - bl_options = {"REGISTER", "UNDO"} - - @classmethod - def poll(cls, context): - return helper.get_active_drawing(context.scene)[0] is not None - - def execute(self, context): - drawing = tool.Ifc.get_entity(context.scene.camera) - target_view = tool.Drawing.get_drawing_target_view(drawing) - subcontext = ifcopenshell.util.representation.get_context( - IfcStore.get_file(), "Plan", "Annotation", target_view - ) - if not subcontext: - return {"FINISHED"} - - proj_coll = helper.get_project_collection(context.scene) - view_coll, camera = helper.get_active_drawing(context.scene) - is_ortho = camera.data.type == "ORTHO" - bounds = helper.ortho_view_frame(camera.data) if is_ortho else None - clipping = is_ortho and target_view in ("PLAN_VIEW", "REFLECTED_PLAN_VIEW") - elevating = is_ortho and target_view in ("ELEVATION_VIEW", "SECTION_VIEW") - - def grep(coll): - results = [] - for obj in coll.all_objects: - element = tool.Ifc.get_entity(obj) - if element and element.is_a("IfcAnnotation") and element.ObjectType == "GRID": - results.append(obj) - return results - - def clone(src): - dst = src.copy() - dst.data = dst.data.copy() - dst.name = dst.name.replace("IfcGridAxis/", "") - dst.BIMObjectProperties.ifc_definition_id = 0 - dst.data.BIMMeshProperties.ifc_definition_id = 0 - return dst - - def disassemble(obj): - mesh = bmesh.new() - mesh.verts.ensure_lookup_table() - mesh.from_mesh(obj.data) - return obj, mesh - - def assemble(obj, mesh): - mesh.to_mesh(obj.data) - return obj - - def localize(obj, mesh): - # convert to camera coords - mesh.transform(camera.matrix_world.inverted() @ obj.matrix_world) - obj.matrix_world = camera.matrix_world - return obj, mesh - - def clip(mesh): - # clip segment against camera view bounds - mesh.verts.ensure_lookup_table() - points = [v.co for v in mesh.verts[0:2]] - points = helper.clip_segment(bounds, points) - if points is None: - return None - mesh.verts[0].co = points[0] - mesh.verts[1].co = points[1] - return mesh - - def elev(mesh): - # put camera-perpendicular segments vertically - mesh.verts.ensure_lookup_table() - points = [v.co for v in mesh.verts[0:2]] - points = helper.elevate_segment(bounds, points) - if points is None: - return None - points = helper.clip_segment(bounds, points) - if points is None: - return None - mesh.verts[0].co = points[0] - mesh.verts[1].co = points[1] - return mesh - - for obj in grep(view_coll): - view_coll.objects.unlink(obj) - - grids = [] - for element in tool.Ifc.get().by_type("IfcGridAxis"): - obj = tool.Ifc.get_object(element) - if not obj: - continue - grids.append((*localize(*disassemble(clone(obj))), element)) - - if clipping: - grids = [(obj, clip(mesh), element) for obj, mesh, element in grids] - elif elevating: - grids = [(obj, elev(mesh), element) for obj, mesh, element in grids] - - for obj, mesh, element in grids: - if mesh is not None: - view_coll.objects.link(assemble(obj, mesh)) - bpy.ops.bim.assign_class(obj=obj.name, ifc_class="IfcAnnotation", context_id=subcontext.id()) - annotation = tool.Ifc.get_entity(obj) - annotation.Name = element.AxisTag - annotation.ObjectType = "GRID" - return {"FINISHED"} - - -class AddSectionsAnnotations(bpy.types.Operator): - bl_idname = "bim.add_sections_annotations" - bl_label = "Add Sections" - bl_options = {"REGISTER", "UNDO"} - - @classmethod - def poll(cls, context): - camera = helper.get_active_drawing(context.scene)[1] - return camera and camera.data.type == "ORTHO" - - def execute(self, context): - scene = context.scene - view_coll, camera = helper.get_active_drawing(scene) - bounds = helper.ortho_view_frame(camera.data) - - drawings = [ - d - for d in scene.DocProperties.drawings - if ( - d.camera is not camera - and d.camera.data.type == "ORTHO" - and d.camera.data.BIMCameraProperties.target_view == "SECTION_VIEW" - ) - ] - - def sideview(cam): - # leftmost and rightmost points of camera view area, local coords - xmin, xmax, _, _, _, _ = helper.ortho_view_frame(cam.data, margin=0) - proj = camera.matrix_world.inverted() @ cam.matrix_world - p_l = proj @ Vector((xmin, 0, 0)) - p_r = proj @ Vector((xmax, 0, 0)) - return helper.clip_segment(bounds, (p_l, p_r)) - - def annotation(drawing, points): - # object with path geometry - name = drawing.name - curve = bpy.data.curves.new(f"Section/{name}", "CURVE") - spline = curve.splines.new("POLY") # has 1 initial point - spline.points.add(1) - p1, p2 = points - z = bounds[4] - 1e-5 # zmin - spline.points[0].co = (p1.x, p1.y, z, 1) - spline.points[1].co = (p2.x, p2.y, z, 1) - obj = bpy.data.objects.new(f"IfcAnnotation/Section/{name}", curve) - obj.matrix_world = camera.matrix_world - return obj - - for d in drawings: - points = sideview(d.camera) - if points is None: - continue - obj = annotation(d, points) - view_coll.objects.link(obj) - - return {"FINISHED"} - - class EditTextPopup(bpy.types.Operator): bl_idname = "bim.edit_text_popup" bl_label = "Edit Text"