Skip to main content
Glama
pzfreo

build123d-mcp

cross_sections

Compute cross-sectional areas at evenly spaced planes along an axis to detect internal voids, wall-thickness variation, or verify profile.

Instructions

Compute cross-sectional areas at evenly spaced planes along an axis. Returns a list of {position, area} pairs. axis: X, Y, or Z (default Z). num_slices: number of planes (default 10, minimum 2). Useful for detecting internal voids, wall-thickness variation, or verifying that a shape's cross-section profile matches a reference. object_name: named object from show() (default: current shape).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
object_nameNo
axisNoZ
num_slicesNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • Core implementation of _cross_sections() — computes cross-sectional areas at evenly spaced planes along X/Y/Z axis using OCC BRepAlgoAPI_Section. Returns list of {position, area} pairs.
    def _cross_sections(shape, axis: str = "Z", num_slices: int = 10) -> list:
        from OCP.BRepAlgoAPI import BRepAlgoAPI_Section
        from OCP.BRepBuilderAPI import BRepBuilderAPI_MakeFace
        from OCP.BRepGProp import BRepGProp
        from OCP.GProp import GProp_GProps
        from OCP.ShapeAnalysis import ShapeAnalysis_FreeBounds
        from OCP.TopAbs import TopAbs_EDGE
        from OCP.TopExp import TopExp_Explorer
        from OCP.TopTools import TopTools_HSequenceOfShape
        from OCP.TopoDS import TopoDS
        from OCP.gp import gp_Dir, gp_Pln, gp_Pnt
    
        axis = axis.upper()
        bb = shape.bounding_box()
    
        if axis == "X":
            lo, hi = bb.min.X, bb.max.X
            pln_dir = gp_Dir(1, 0, 0)
            make_pnt = lambda pos: gp_Pnt(pos, 0, 0)
        elif axis == "Y":
            lo, hi = bb.min.Y, bb.max.Y
            pln_dir = gp_Dir(0, 1, 0)
            make_pnt = lambda pos: gp_Pnt(0, pos, 0)
        else:
            lo, hi = bb.min.Z, bb.max.Z
            pln_dir = gp_Dir(0, 0, 1)
            make_pnt = lambda pos: gp_Pnt(0, 0, pos)
    
        span = hi - lo
        lo_s = lo + span * 0.01
        hi_s = hi - span * 0.01
        num_slices = max(num_slices, 2)
        step = (hi_s - lo_s) / (num_slices - 1)
    
        results = []
        for i in range(num_slices):
            pos = lo_s + i * step
            plane = gp_Pln(make_pnt(pos), pln_dir)
    
            section = BRepAlgoAPI_Section(shape.wrapped, plane, False)
            section.Build()
    
            edges = TopTools_HSequenceOfShape()
            exp = TopExp_Explorer(section.Shape(), TopAbs_EDGE)
            while exp.More():
                edges.Append(exp.Current())
                exp.Next()
    
            wires = TopTools_HSequenceOfShape()
            ShapeAnalysis_FreeBounds.ConnectEdgesToWires_s(edges, 1e-7, False, wires)
    
            total_area = 0.0
            for j in range(1, wires.Length() + 1):
                wire = TopoDS.Wire_s(wires.Value(j))
                try:
                    face_maker = BRepBuilderAPI_MakeFace(plane, wire)
                    if face_maker.IsDone():
                        face = face_maker.Face()
                        props = GProp_GProps()
                        BRepGProp.SurfaceProperties_s(face, props)
                        total_area += abs(props.Mass())
                except Exception:
                    pass
    
            results.append({"position": round(pos, 4), "area": round(total_area, 4)})
    
        return results
  • Public cross_sections() entry point — resolves the shape from session and delegates to _cross_sections helper.
    import json
    
    
    def cross_sections(session, object_name: str = "", axis: str = "Z", num_slices: int = 10) -> str:
        from build123d_mcp.tools.measure import _resolve_shape, _cross_sections
        shape = _resolve_shape(session, object_name)
        return json.dumps(_cross_sections(shape, axis, num_slices), indent=2)
  • MCP tool registration via @mcp.tool() decorator on cross_sections(). This is the server-level tool definition with its description and parameter schema.
    @mcp.tool()
    def cross_sections(object_name: str = "", axis: str = "Z", num_slices: int = 10) -> str:
        """Compute cross-sectional areas at evenly spaced planes along an axis. Returns a list of {position, area} pairs. axis: X, Y, or Z (default Z). num_slices: number of planes (default 10, minimum 2). Useful for detecting internal voids, wall-thickness variation, or verifying that a shape's cross-section profile matches a reference. object_name: named object from show() (default: current shape)."""
        return _session.cross_sections(object_name, axis, num_slices)
  • Worker dispatch routing the 'cross_sections' operation to the cross_sections handler.
    if op == "cross_sections":
        from build123d_mcp.tools.cross_sections import cross_sections
        return cross_sections(session, **args)
  • WorkerSession.cross_sections() proxy method — sends the cross_sections call to the worker subprocess via pipe.
    def cross_sections(self, object_name: str = "", axis: str = "Z", num_slices: int = 10) -> str:
        return self._call(
            "cross_sections",
            {"object_name": object_name, "axis": axis, "num_slices": num_slices},
            self._SHORT_TIMEOUT,
        )
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description implies a non-destructive read operation by stating 'compute', but it does not explicitly confirm that it does not modify the shape or mention any authorization requirements or side effects.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise, front-loads the core purpose, and efficiently covers parameters and use cases without unnecessary information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a tool with three parameters and an output schema, the description adequately explains the return format and practical applications, making it complete for typical usage.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Despite 0% schema description coverage, the description explains each parameter's meaning, defaults, and constraints (e.g., axis options, num_slices minimum, object_name context), fully compensating for the missing schema descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool computes cross-sectional areas at evenly spaced planes along an axis, and it distinguishes itself from siblings like 'measure' or 'shape_compare' by specifying the exact output and use cases.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit use cases such as detecting internal voids and verifying cross-section profiles. However, it does not explicitly state when not to use this tool or how it compares to siblings like 'clearance' or 'interference'.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/pzfreo/build123d-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server