--- jupyter: description: 'Section views in planex2d: px.Drawing cuts an OpenCASCADE solid at a plane, hatches the cut faces and leaves the hidden edges out, and Section marks the cut on the view it is taken from. A bearing plate cut through its bore, a manifold block cut at the height of its channels, and a pipe flange in full section.' --- # Sections `px.Drawing(part, plane, section=True)` cuts the solid at the plane and draws the material behind it, seen along the plane. The cut faces are hatched, and the hidden edges are left out. A section is named by its letters, `view_name="Section view A-A"` or `"A-A"`, and `dw.Section(section)` marks the cut on the view it is taken from: - the cutting line across the part, narrow, long-dashed and dotted, wide at its ends; - an arrow at each end that points the way the section is seen, with the section's letter. ```python import math import netgen.occ as occ import planex as px ``` ```python nbsphinx="hidden" plate = px.Sketch(auto_constraint=True) plate.RectangleC(120, 80, id="plate") plate.Constrain("plate.center", "origin", px.Coincident) plate.Constrain("plate.Line.1", px.Horizontal) plate.Constrain("plate.Line.1", px.Distance, 120, id="length") plate.Constrain("plate.Line.2", px.Distance, 80, id="width") plate.Fillet(["plate.Line.1.start", "plate.Line.2.start", "plate.Line.3.start", "plate.Line.4.start"], 8, id=["corner_1", "corner_2", "corner_3", "corner_4"]) for k in (2, 3, 4): plate.Remove(f"corner_{k}.r") plate.Constrain(f"corner_{k}", "corner_1", px.Equal) plate.Circle(20, id="bore") plate.Constrain("bore.center", "origin", px.Coincident) plate.Constrain("bore", px.Diameter, 40, id="bore_d") plate.Circle(30, id="bolt_circle", construction=True) plate.Constrain("bolt_circle", "bore", px.Concentric) plate.Constrain("bolt_circle", px.Diameter, 60, id="pitch") plate.Circle(4.5, center=(30, 1), id="hole") plate.Constrain("hole.center", "bolt_circle", px.Coincident) plate.Constrain("hole.center", "H", px.Coincident) plate.Constrain("hole", px.Diameter, 9, id="hole_d") plate.CircularPattern(["hole"], "origin", 4, id="holes") ``` ## The bearing plate cut through its bore The example is the bearing plate with its hub from [Views of solids](solid-views.md): ```python part = px.Pad(plate, 10) top = part.faces.Max(occ.Z) part = part + px.Pad(px.QuickSketch(top).Circle((0, 0), 24).Circle((0, 0), 20), 15) ``` The section A-A lies in the front plane, through the axis of the bore and two of the bolt holes. It shows the plate and the wall of the hub in section, and the bolt holes and the bore as gaps in it. It takes the place of the front view, and on the top view, `Section` marks where it is cut: ```python section = px.Drawing(part, px.Front, section=True, view_name="Section view A-A", unit=px.mm) top_view = px.Drawing(part, px.Top, unit=px.mm) top_view.Section(section) px.Sheet(section, top_view) ``` ```python nbsphinx="hidden" base = px.Sketch(auto_constraint={"horizontal": True, "vertical": True}) base.Rectangle(70, 50, id="base") base.Constrain("base.Line.1.start", "origin", px.Coincident) base.Constrain("base.Line.1", px.Distance, 70, id="length") base.Constrain("base.Line.2", px.Distance, 50, id="depth") block = px.Pad(base, 40) def port(block, face, edge_a, a, edge_b, b, depth): spot = px.Sketch(face) spot.Project(edge_a, id="edge_a") spot.Project(edge_b, id="edge_b") spot.Circle(14 / 2, center=spot.ToHV(tuple(face.center)), id="spot") spot.Constrain("spot", px.Diameter, 14, id="spot_d") spot.Constrain("spot.center", "edge_a.Edge.0", px.Distance, a, id="from_a") spot.Constrain("spot.center", "edge_b.Edge.0", px.Distance, b, id="from_b") block = px.Pocket(block, spot, 2) channel = px.Sketch(face) channel.Circle(8 / 2, center=spot.Location("spot.center"), id="channel") channel.Constrain("channel", px.Diameter, 8, id="channel_d") return px.Pocket(block, channel, depth), spot front = block.faces.Min(occ.Y) block, p = port(block, front, front.edges.Min(occ.X), 15, front.edges.Min(occ.Z), 20, 34) top = block.faces.Max(occ.Z) block, a = port(block, top, top.edges.Min(occ.X), 15, top.edges.Min(occ.Y), 30, 24) right = block.faces.Max(occ.X) block, b = port(block, right, right.edges.Min(occ.Y), 30, right.edges.Min(occ.Z), 20, 59) top = block.faces.Max(occ.Z) holes = px.Sketch(top) holes.Project(top.edges.Min(occ.X), id="left_edge") holes.Project(top.edges.Min(occ.Y), id="front_edge") holes.Circle(6.6 / 2, center=(48, 12), id="front_hole") holes.Circle(6.6 / 2, center=(48, 40), id="back_hole") holes.Constrain("back_hole", px.Diameter, 6.6, id="hole_d") holes.Constrain("front_hole", "back_hole", px.Equal) holes.Constrain("front_hole.center", "left_edge.Edge.0", px.Distance, 50, id="hole_x") holes.Constrain("back_hole.center", "left_edge.Edge.0", px.Distance, 50) holes.Constrain("front_hole.center", "front_edge.Edge.0", px.Distance, 10, id="front_y") holes.Constrain("back_hole.center", "front_edge.Edge.0", px.Distance, 42, id="back_y") block = px.Pocket(block, holes, until=px.last) ``` ## A section at the height of the channels The example is the block of the exercise [Manifold block](../../exercises/manifold-block.md), built as on that page. It is 70 × 50 × 40, with three ports, P in front, A on the top and B on the right, joined by channels drilled inside, and two mounting holes from the top. The channels from P and from B run 20 above the base, and only a section at that height shows how they meet. The section A-A cuts the block at $z = 20$ and is seen from above, a `px.Plane` with its origin at that height and its normal up. The mounting holes run through the cut, so the section carries the dimensions of their sketch on the top face at their true lengths. `Hide` leaves out the second hole's distance from the left edge, which the first hole's already gives, and `Place` puts the holes' diameter and that of port P on leaders, so that their values stay clear of the hatching and of the port's circle. The section is no standard view, so `Add` places it below the front view, and `Section` marks the cut on the front view: ```python section = px.Drawing(block, px.Plane(origin=(0, 0, 20), normal=(0, 0, 1)), section=True, view_name="A-A", unit=px.mm) section.Add(holes).Hide("Distance.1").Place("hole_d", "ne", leader=True) front_view = px.Drawing(block, px.Front, unit=px.mm).Add(p).Place("spot_d", "se", leader=True) front_view.Section(section) sheet = px.Sheet(front_view) sheet.Add(section, at=(0, -90)) sheet ``` The section shows the channels from P and B meeting the channel down from A. What the drilling takes out of the block is therefore one passage, besides the two mounting holes: ```python taken = occ.Box(occ.Pnt(0, 0, 0), occ.Pnt(70, 50, 40)) - block print(len(taken.solids), "pieces drilled out") ``` ```python nbsphinx="hidden" half = px.Sketch(px.XZ, auto_constraint={"horizontal": True, "vertical": True}) half.Move((24.5, 0)).Line(10.5, id="hub_end") half.Turn(90).Line(12, id="hub") half.Turn(-90).Line(30, id="plate_back") half.Turn(90).Line(16, id="rim") half.Turn(90).Line(26, id="plate_front") half.Turn(-90).Line(2, id="raised_side") half.Turn(90).Line(14.5, id="raised_face") half.Close(id="bore") half.Constrain("hub_end.start", "H", px.Coincident) half.Constrain("bore", "V", px.Distance, 49 / 2, id="bore_r") half.Constrain("hub", "V", px.Distance, 70 / 2, id="hub_r") half.Constrain("rim", "V", px.Distance, 130 / 2, id="plate_r") half.Constrain("raised_side", "V", px.Distance, 78 / 2, id="raised_r") half.Constrain("hub", px.Distance, 12, id="hub_l") half.Constrain("rim", px.Distance, 16, id="plate_t") half.Constrain("raised_side", px.Distance, 2, id="raised_h") flange = half.Face().ToOCCFace().Revolve(occ.Axis((0, 0, 0), occ.Z), 360) holes = px.Sketch(px.Plane(px.XY, 28), auto_constraint=True) holes.Circle(100 / 2, id="bolt_circle", construction=True) holes.Constrain("bolt_circle.center", "origin", px.Coincident) holes.Constrain("bolt_circle", px.Diameter, 100, id="bolt_circle_d") holes.Circle(18 / 2, center=(36, 34), id="hole") holes.Constrain("hole.center", "bolt_circle", px.Coincident) holes.Expression("hole.center.h = hole.center.v", id="at_45") holes.Constrain("hole", px.Diameter, 18, id="hole_d") holes.CircularPattern(["hole"], "origin", 4, id="pattern") flange = px.Pocket(flange, holes, 16) ``` ## A turned part in full section The example is the slip-on flange of the exercise [Pipe flange](../../exercises/pipe-flange.md), built as on that page. It is a turned part around a bore of 49, a plate of 130 and 16 thick with a hub of 70 and 12 long behind it and a raised face of 78 and 2 high in front, with four bolt holes of 18 on a bolt circle of 100. A turned part is drawn in a full section through its axis, here the front plane, so that its profile shows on both sides of the axis. Its diameters are no dimensions of a sketch on that plane, so `Measure` writes each as a length across the axis with "⌀" in front, and `Axis` draws the axis (see [Center lines and axes](center-lines.md)). The top view carries the bolt holes' sketch. `Hide` leaves out the first hole's coordinates, which the rule that puts it at 45° adds as reference dimensions, and the bolt circle's diameter goes on a leader: ```python section = px.Drawing(flange, px.Front, section=True, unit=px.mm).Axis((0, -4), (0, 34)) section.Measure((-65, 12), (65, 12), value="⌀130", offset=36).Measure((-35, 0), (35, 0), value="⌀70", offset=12) section.Measure((-24.5, 30), (24.5, 30), value="⌀49", offset=6) section.Measure((-39, 30), (39, 30), value="⌀78", offset=14) section.Measure((65, 0), (65, 12), offset=9).Measure((65, 12), (65, 28), offset=9) section.Measure((39, 0), (39, 30), offset=47) top_view = px.Drawing(flange, px.Top, hidden=False, unit=px.mm).Add(holes).Hide("Reference.1", "Reference.2") top_view.Place("bolt_circle_d", 120, leader=True) px.Sheet(section, top_view) ``` The section is the profile of three rings, the hub, the plate and the raised face, and the volume is theirs less the bolt holes through the plate: ```python exact = math.pi * ((35**2 - 24.5**2) * 12 + (65**2 - 24.5**2) * 16 + (39**2 - 24.5**2) * 2 - 4 * 9**2 * 16) print("volume", flange.mass, "exact", exact) ``` See [Views of solids](solid-views.md) for views without a cut, and [Views and sheets](sheets.md) for placing views on a sheet.