Feature Parameters#
Read each recognised hole, pocket, boss, slot and groove as the parameters a designer would have typed to make it, and find the features repeated in a line, a grid, on a circle or across a mirror.
Note
Prerequisites: Depression and Protrusion Feature Recognition
Feature Parameters#
Recognition says which faces make a hole, a pocket or a boss. Rebuilding or editing that feature takes numbers
instead: the diameters and depths of a hole’s steps, the outline and height of a boss, the depth of a pocket, the
radius of the blend at its foot. read_all_feature_parameters reads them off each feature’s own faces into plain,
frozen records, in the units the part was read in.
Reading Every Feature of a Part#
The function takes the features recognise_depressions_and_protrusions returns (see
Depression and Protrusion Feature Recognition) and the same face adjacency graph. The plate below is the first part of that page:
from volmdlr.model import VolumeModel
from volmdlr_tools.features.extractors.depression_protrusion import recognise_depressions_and_protrusions
from volmdlr_tools.graph.faces import AttributedAdjacencyGraph
from volmdlr_tools.reverse_engineering.techniques.feature_parameters import read_all_feature_parameters
solid = VolumeModel.from_step("features_on_a_plate.step").primitives[0]
aag = AttributedAdjacencyGraph(shape=solid)
features = recognise_depressions_and_protrusions(aag)
readings = read_all_feature_parameters(features, aag)
for feature, record in zip(features, readings.records):
print(feature.subtype, None if record is None else record.kind)
# through_hole hole
# pocket pocket
# protrusion boss
# protrusion None
# protrusion None
# protrusion boss
# blind_hole hole
for failure in readings.failures:
print(failure.index, failure.reason.split(";")[0])
# 3 the feature made of faces [19, 20, 21, 38] has no round wall to give it an axis
# 4 the faces [22, 23, 24, 25, 40] are not a round wall closed by one flat floor or top
The result is a FeatureReadings:
records: one entry per feature, in the order given; its parameters, orNonewhen it could not be read or was read as part of another;failures: oneFeatureFailureper feature that could not be read, with itsindex, itsface_idsand thereason, so a part is read whole and the features left over can be looked at or handed elsewhere;absorbed: for a hole recognised in pieces, such as the cone a countersink’s cylinder opens into, the index of the feature whose record holds its faces.
On the plate, the hole, the pocket, the round pad, the pin and the blind hole are read. The gusset standing against the pad and the rib with a half-round top are not: neither is an outline carried from one flat base to a flat top. Below, the counterbored hole is blue, the pocket purple, the pad and the pin orange, and the two features left unread grey; the blind hole is drilled into the far side.

To read one feature, read_feature_parameters(feature, aag, descendants) gives its record and raises
FeatureParameterError with the reason when it cannot be read. The record types are in volmdlr_tools.parametrics.
Every record has a kind: "hole", "pocket", "boss", "slot" or "groove".
Holes#
A round hole is a HoleStack, read from the plane it is drilled from: origin, where its axis meets that plane;
axis, pointing into the material; entry, the surface it is drilled from; through; depth, to the tip of a
drill point; and its steps in order of depth. Each step is a HoleStep:
kind:"counterbore", the wide cylinder at the entry that a narrower one follows through a flat shoulder;"countersink"or"chamfer", a cone widening to the entry, a chamfer when it widens the bore by at most a third of its radius;"bore", any other cylinder;"recess", a wider cylinder away from the entry;"taper", a cone inside the hole;"drill_point", the cone ending a blind hole, or ending a hole whose drill point broke out through the far side of the part, which is still read from the end it was drilled from;start_depth,end_depthandlength, along the axis from the entry;start_diameterandend_diameter,0at the tip of a drill point, the width of the opening where one broke out;included_angle_degrees, the angle between opposite sides of a cone,0for a cylinder andNonefor a step with no length;face_ids, the faces of the part it is made of.
A hole running through is read from the end it is drilled and finished from: the end with a counterbore rather than a
countersink, a countersink rather than a chamfer, a chamfer rather than a plain bore. When both ends are alike, as for
a plain hole, it is read drilled down its axis: from the end facing +x, +y or +z, whichever its axis runs most along,
z before y before x when it runs as much along several, as a hole in a plate lying flat is drilled from the top. Its entry names the flat faces round
its mouth at that end.
The entry is a point of the part: origin is where the axis meets the face the hole opens through, which
entry_face_id names, and entry_planar says whether that face is flat. A hole opening through a curved face, as the
cone under a turned disc, or through a flat that leans across its axis, enters where its axis meets that face, even
though its wall reaches further out on the side the face falls away; the first step then starts at the entry, depth
0. Its entry is the plane of a flat face, or, for a curved one, the plane square to the axis through origin,
which touches the face only there. A hole whose axis meets no face beside its first wall names none, and is entered
where that wall starts.
bore is the narrowest cylinder, the one the other steps are cut around (None for a hole with no cylinder), and
step_of(kind) the first step of a kind. A slot or a cavity that crosses a hole and breaks its wall does not part it
into two bores: it is one of the hole’s interruptions, with the depths it spans and its faces.
hole = readings.records[0]
print(hole.through, [(step.kind, step.start_diameter, step.end_depth) for step in hole.steps])
# True [('counterbore', 0.012, 0.003), ('bore', 0.006, 0.008)]
print(hole.bore.start_diameter, hole.step_of("counterbore").length)
# 0.006 0.003
The plate is read in metres, so the counterbore is 12 mm across and 3 mm deep. The steps are those a designer would
have typed, so they differ from the steps recognition gives on the feature itself (see Hole Steps in
Depression and Protrusion Feature Recognition): those also list floors and blends, by radius, while a HoleStack lists only the
cylinders and cones, by diameter and depth, a shoulder being where one step ends and the next begins.
On holes_types.step, a blind hole ends in a drill point. The section below is drawn from the second hole the
example prints: a counterbore, a bore, and the drill point’s cone, each step with the depth it ends at.

solid = VolumeModel.from_step("holes_types.step").primitives[0]
aag = AttributedAdjacencyGraph(shape=solid)
holes = read_all_feature_parameters(recognise_depressions_and_protrusions(aag), aag)
for hole in holes.records[4:6]:
print(hole.through, [step.kind for step in hole.steps])
point = hole.step_of("drill_point")
print(round(point.included_angle_degrees), round(hole.depth, 4))
# False ['bore', 'drill_point']
# 118 0.0177
# False ['counterbore', 'bore', 'drill_point']
# 118 0.0177
A hole with a rounded floor, filleted or drilled with a ball end, is not read as a stack of steps; neither is one with any rounded step, such as a counterbore whose floor is filleted into its wall.
Pockets, Bosses and Slots#
A pocket, a boss or a slot is an outline drawn on its base and carried to a floor or a top. All three hold:
base, the surface the feature stands on or sinks into, aBaseSurface("plane"or"cylinder", with itsorigin, itsaxisand, for a cylinder, itsradius);frame, the sketch frame: its origin on the base, its third axis pointing out of the material along the way the outline is carried;outlines, the closed outlines in that frame, boundaries before the holes they enclose;draft_angle, in radians, positive when the feature narrows away from its base;tilt, in radians, the angle between the frame’s third axis and the base’s normal; a round pocket cut at an angle is read from its own axis and carries its tilt;face_ids, the faces of the feature.
A PocketParameters adds depth, floor_blend, rim_blend, floor_face_ids, through (a window rather than a
pocket with a floor) and from_floor (its frame sits on a floor that is not parallel to its base). A
BossParameters adds height, root_blend, top_blend, top_face_ids and until, which says where the boss
stops: "height" at its own top, "next" where it meets the part, "plane" at a top that leans from its base, as a
lug cut back at an angle. A boss cut back so names that plane in top_plane, a BaseSurface with a point of the
plane as its origin, its normal out of the material as its axis and the faces of the top; its height is then how
high its walls reach, under the highest point of the top. Every other boss has no top_plane. Both say whether they
are one circular outline.
A SlotParameters is two parallel sides closed by half circles: its shape gives the centre, overall length,
width and rotation in the frame, with depth, through, floor_blend and rim_blend. A thin cut bounded by two
parallel walls and open on every other side, such as a saw cut, is a slot with symmetric set: its frame lies midway
between its walls, its shape is the rectangle covering them, and its depth is the distance between the walls, cut
half on either side.
A groove turned about an axis is a GrooveParameters: its axis_origin, halfway along it, and axis; the frame of
the half plane its profile is drawn in, as (radius, position along the axis); the surface it opens_on; and
full_turn, False when windows cut through its walls.
A document’s pocket, slot, step, cut and boss records are read through record_parameters(reading, document, index), which gives the parameters the record’s faces read as. A step or a cut that no outline loop of the
document reads is read from where its faces meet the faces it opens in, and a step of a hole is refused naming the
hole record whose parameters hold it: step_holder(reading, document, index) gives that record’s position.
Bosses that are ribs#
A boss that is a thin plate standing on the part, such as a gusset between a hub and its flange, reads as no prism: its
two sides are near-parallel flat faces. record_parameters then gives a RibPlate, whose kind is "rib": its
side_face_ids, its thickness at the root, its draft_angle, the frame of its mid plane and its profile there,
drawn in the frame’s u and v axes. A rib whose section at the mid plane cannot be read gives no parameters: the
record is refused, and the refusal says why the profile is missing.
Blend Radii#
Every blend a record carries is a BlendRadius:
value, the radius;certain:Truewhen it was read off a cylinder or a torus, or taken from the radius recognition measured, andFalsewhen it was estimated from curvature, as a free-form blend allows, or when the faces of the blend disagree;face_ids, the blend faces it was read from.
A radius read exactly is kept as read, so a 1/8” fillet stays 3.175 mm. An estimated one within 0.3 % of a round value a designer would have typed becomes that value.
pocket = readings.records[1]
print(pocket.depth, pocket.rim_blend.value, pocket.rim_blend.certain, pocket.floor_blend)
# 0.004 0.001 True None
Rounds and Chamfers Worked on Edges#
The rounds and chamfers recognise_features finds on a part’s edges are its blend and chamfer records, worked
last. record_parameters(reading, document, index) reads each one from the part alone, so a document that was saved
and loaded still gives them.
A round is a BlendParameters:
radius, the radius it is made with, the smallest where it changes along the round, andwidest_radius, the largest:varyingsays whether they differ;certain:Falsewhen a radius was only estimated from how a free-form face curves;vexity:"convex"for a round taking outside edges off,"concave"for a fillet filling inside corners;edges: each edge it was worked on, as aWorkedEdge;stops_at: the faces it runs into at its ends, which it is not tangent to;afterandlayer: where it runs on over a round of a larger radius, the records of those rounds, which are made before it, and how many rounds come before it that way.
A chamfer is a ChamferParameters: the two distances it cuts back along the faces of its edges, the shorter first
(equal when they agree), its vexity, "concave" for an inside bevel filling a corner, and its edges.
A bevel turned on the rim of a turned part, a cone between the face square to the axis and the diameter, is a chamfer
of the circle where they met, with its two distances along the axis and across it. A cone at the mouth of a bore stays
a step of the hole (a "chamfer" or "countersink" step), and a bevel turned before flats were milled across it, as
on a hexagon nut, stays in the turned profile: it is no chamfer of an edge the part has. A face between two pieces of
one surface, as a wrench flat between the two halves of the round it was milled across, is no chamfer either.
A WorkedEdge names the two faces of the part that met along the edge, in face_ids, and, in sharp, where the edge
ran before it was worked: a RimEdge on the line or the circle where those two faces, carried on past the round or
the chamfer, meet, with its length. A chamfer names first the face its shorter distance runs along. A corner where
a round turns from one edge onto the next is a face of the round but names no edge of its own.
from volmdlr.model import VolumeModel
from volmdlr_tools.features import PartReading, recognise_features, record_parameters
solid = VolumeModel.from_step("nist_ctc_01_asme1_nx1980_rd-ap242e3.stp").primitives[0]
reading, document = PartReading(solid), recognise_features(solid, body=True)
fillet = record_parameters(reading, document, 33)
print(fillet.radius, fillet.vexity, fillet.after, fillet.layer)
# 0.01 concave (24,) 1
print([edge.face_ids for edge in fillet.edges])
# [(20, 68)]
A round or a chamfer whose faces the part’s reading does not take for one, or a round whose radius cannot be read, is
refused with a FaceRefusal naming the face.
Bodies#
Read with body=True, a part’s body records say what it was made from. record_parameters gives an extruded body or
a slab ("extrusion" or "drafted_extrusion") as an ExtrudedBodyParameters, with the profiles it was drawn from,
and a turned body ("revolution") as a RevolvedBodyParameters.
Extruded bodies#
An ExtrudedBodyParameters holds profiles, one per stretch of the body from the lowest up: a body pulled in one go
gives one, a stepped plate read as several slabs gives one per slab. It also gives the direction the profiles are
extruded along, the levels the whole body spans along it, and the face_ids of the record. Each ExtrudedProfile
holds:
frame, the plane the outlines are drawn in, its third axis along the direction of extrusion (alsodirection), andlevels, where the profile starts and stops along that direction, the start the lower;ends, what closes the profile at its start and at its end:"cap"for a flat face of the part,"parent"for the body it stands on,"read"for the end of the stretch the walls were read over;loops, its outlines, the outer ones first.outlines,holesandislandspick them by role,releasesays which way the profile leaves a mould andcompletewhether every outline of the part’s section is in it;loops_at(level), the outlines carried along their walls to another level.
A ProfileLoop is one outline: its loop, counter-clockwise in the (u, v) axes of the frame; its role, "outline",
"hole" in the material or "island" standing in a hole; its depth, how many other outlines enclose it; its
draft_angle and the edge_drafts of each of its edges, in radians, signed so that a hole widening along the
direction counts as an outline growing; and the edge_face_ids of the faces its edges run along.
plate = VolumeModel.from_step("stepped_plate.step", reading_unit="MM").primitives[0]
reading, document = PartReading(plate), recognise_features(plate, body=True)
body = record_parameters(reading, document, 0)
(profile,) = body.profiles
print(body.kind, profile.direction, profile.levels, profile.ends)
# extruded_body (0.0, 0.0, 1.0) (-8.0, 8.0) ('cap', 'cap')
(outline,) = profile.loops
print(outline.role, outline.depth, round(outline.loop.signed_area), len(outline.edge_drafts), outline.draft_angle)
# outline 0 208 8 0.0
Turned bodies#
A RevolvedBodyParameters holds:
frame, the half plane the profile is drawn in: its origin on the axis,ualong the axis (alsoaxis, withaxis_origin),vthe direction away from the axis the turn starts from, andwthe way it turns;chains, the profile asRevolvedChains of lines and arcs, each(t, r):talong the axis from the frame’s origin,rthe distance from the axis. A chain isclosed, or runs from the axis out and back to it, as a solid shaft’s does;angle, in radians, how far round the profile is turned fromvtowardsw: a whole turn, whichfull_turnsays, or less;face_ids, the faces of the body record.
The profile is read face by face from the faces the turn sweeps, not from a cut through the part, so the holes and
flats made in the body later leave it whole. A corner a chamfer record bevels is given sharp, the chamfer being worked
on it afterwards. A body whose faces give no line or arc, as one turned from a free-form curve, is refused with a
FaceRefusal naming that face. A revolution record that is not a body record
(the turned profile of a part read without body=True) is refused: only a body reading gives a profile.
solid = VolumeModel.from_step("revolution-with-toroidal-face.step").primitives[0]
reading, document = PartReading(solid), recognise_features(solid, body=True)
body = record_parameters(reading, document, 0)
print(body.kind, body.full_turn)
# revolved_body True
(chain,) = body.chains
print(chain.closed, len(chain.primitives), [p.kind for p in chain.primitives].count("arc"))
# True 11 3
bevel = record_parameters(reading, document, 11)
print(bevel.kind, [round(distance, 6) for distance in bevel.distances], round(bevel.edges[0].sharp.circle_radius, 6))
# chamfer [0.001, 0.001] 0.01
The part is a sleeve with a collar, the collar’s rim rounded: one closed chain, the bore at 7.5 mm from the axis. The bevel on the rim of its end is the chamfer record 11, worked on the corner of the profile 10 mm from the axis.

Units and Angles#
Every length is in the units of the part as it was read. An angle a record gives in degrees says so in its name
(included_angle_degrees, and the angles of a circular pattern below); every other angle, such as a draft or a tilt,
is in radians. A value that cannot be read is None.
Repeated Features#
detect_patterns(records, aag) finds the features that are the same feature in several places, with identical
parameters the same way round, and how they are laid out:
Pattern |
Holds |
|---|---|
|
|
|
|
|
|
|
two |
Each pattern names its members by index into records, and a feature belongs to at most one pattern. A group of
identical features that is none of these, such as two bolt circles of the same holes, is left whole: find it with
identical_groups(records) and place its features one by one. A feature with no twin the same way round is paired
with its mirror image, when it has one. On the machined bracket of Depression and Protrusion Feature Recognition, the two blind
holes in its underside make a line:
from volmdlr_tools.reverse_engineering.techniques.feature_parameters import detect_patterns, identical_groups
solid = VolumeModel.from_step("machined_bracket.step").primitives[0]
aag = AttributedAdjacencyGraph(shape=solid)
bracket = read_all_feature_parameters(recognise_depressions_and_protrusions(aag), aag)
print(identical_groups(bracket.records))
# ((17, 18),)
for pattern in detect_patterns(bracket.records, aag):
print(pattern.kind, pattern.members, pattern.count, round(pattern.step.norm(), 4))
# linear (17, 18) 2 0.0454
Of the bracket’s 19 features, 7 are read. The four mounting holes, whose counterbore floors are rounded into their walls, six of its ten windows, whose walls do not close into one outline when they are cut, and both its pockets are among its failures.
See Also#
Depression and Protrusion Feature Recognition - Recognising the features read here
Hole Feature Recognition - Hole types