Turned Parts#
Read a turned part as the profile it is turned from and the features that stand on that body, with the faces it cannot explain and why.
Note
Prerequisites: Attributed Adjacency Graph (AAG)
Tip
Tutorial Data File: revolution-with-conical-face.step
Turned Parts#
A turned part is a body of revolution with features standing on it: a shaft with a keyway, a flange with a bolt
circle, an eye bolt. RevolvedShapeRecognizer.turned_part reads such a part as two things:
its skin: the faces that turn about the part’s axis, and the flat faces that close them. Together they give the profile that is turned to make the body;
its features: every other group of faces, read as a feature standing on that body. A hole, a pocket or a boss is a straight prism along one direction, perhaps with its edges broken by a chamfer or a blend; a body turned about an axis of its own, such as the eye of an eye bolt, is a turned feature.
The reading says which faces it explains and which it does not, and why.
Quick Start#
from collections import Counter
from volmdlr.model import VolumeModel
from volmdlr_tools.shapes.recognizers import RevolvedShapeRecognizer
volume_model = VolumeModel.from_step("data/step/revolution-with-conical-face.step")
recognizer = RevolvedShapeRecognizer(shape=volume_model.primitives[0])
turned = recognizer.turned_part
print(turned.explains_every_face, turned.operation_count)
# True 22
print(turned.axis_direction, len(turned.skin_face_ids))
# Vector3D(1.0, -0.0, -0.0) 27
print([(chain.closed, len(chain.primitives)) for chain in turned.chains])
# [(True, 16)]
print(Counter(feature.kind for feature in turned.features))
# Counter({'pocket': 21})
pocket = turned.features[0]
print(sorted(pocket.face_ids), round(pocket.depth, 6), pocket.through, sorted(pocket.host_face_ids))
# [0, 66] 0.006 False [41, 43]
The part is one closed profile turned once, and 21 pockets cut into it: 22 operations rebuild it.

The profile read from revolution-with-conical-face.step, drawn from turned.chains: the closed chain in blue,
the material it encloses in sand, and the axis dashed. Turning it once about the axis gives the body the 21
pockets are cut into.

The same part in the viewer: the 27 faces of the turned skin (skin_face_ids) in sand, the faces of the 21 pockets
cut into it in blue: the ring of bolt holes, the larger openings round the hub and the keyway in the bore.
Reading the part#
Member of |
Description |
|---|---|
|
The part read as a profile turned about its axis with features standing on it, as a |
|
Why the part was not read at all, as a |
The reading is available whether or not perform() recognises the part, and does not depend on it: its refusals
say which groups of faces are not features, and why. When the reading explains every face, about the same axis the
shape is built on, perform() no longer asks for the share of revolved faces or area to reach
min_revolved_face_ratio or min_revolved_area_ratio: a part with many features on a small skin is still a
revolved shape. The RevolvedShape that perform() gives holds the reading as turned_part.
A part with more than 60 free-form faces, as threads, knurls and gear teeth make, is not read: turned_part is
None and turned_refusal gives that reason with those faces.
When the reading about the axis that turns the most area needs more than one feature, the part is also read about the next axis across it, and the reading that needs fewer operations is kept. An eye bolt is read about its shank, with the eye as one turned feature, rather than about its eye with the shank as bosses.
TurnedPart#
The profile is drawn in the axes (t, r): t along the axis from axis_origin, and r the distance from the
axis. The axis origin is placed where the part starts along the axis, so the profile runs from zero, as a designer
draws it.
Member |
Description |
|---|---|
|
A point of the axis and its unit direction |
|
The faces of the skin |
|
What each skin face contributes to the profile, as |
|
The profile: closed chains of lines, circular arcs and arcs of ellipses in |
|
The body of revolution: its axis, its profile |
|
The features standing on the skin, parents before the features that stand on them |
|
The bodies turned about an axis of their own, as |
|
The groups of faces that are not features, each a |
|
Why the bands do not close into a profile, with its faces; |
|
How many operations rebuild the part: the profile’s turn, then each feature |
|
Whether the skin closes into a profile and every other face is a feature’s |
A MeridianBand gives the skin face (face_id), its own meridian (primitive, a line or an arc in (t, r), with
its kind, start and end) and open_ends: whether each end of the meridian is where a feature takes over the
face’s outline rather than where the face meets another skin face. A face a feature cuts into is given whole.
Each feature is one of the shared parameter records of volmdlr_tools.parametrics.features:
PocketParametersfor material taken away, with itsdepth, whether it isthrough, its floor and rim blends;BossParametersfor material added, with itsheight, its root and top blends, anduntil:"height"when it stops at its own top,"next"when it rises until it meets the part,"plane"when it is cut back to a sloping top, the plane it then gives astop_plane;HoleStackfor a drilled hole: its axis, entry plane, thestepsof its profile in order of depth, and whether it isthrough.
The prisms carry the faces they are made of (face_ids), the faces of the part they stand on or open through
(host_face_ids), their sketch frame and outlines, and the chamfers and blends along their rim (breaks).
A TurnedFeature gives the faces it explains (face_ids) and its own revolution, read as the part’s profile is.
Partial turns#
A body turned less than a whole turn, closed at both ends of its turn by flat faces through its axis, is read as a
turned part too; those flat faces are skin. turned.revolution.turn gives where the turn starts and how far it
sweeps, both in radians, the way the right hand turns about the axis direction. A whole turn is (0.0, 2π):
print(turned.revolution.turn)
# (0.0, 6.283185307179586)
The body of a turned part#
turned_body_faces(reading), in volmdlr_tools.reverse_engineering.techniques.turns, takes a PartReading of the part and gives the faces of the body a lathe
turned: the stock a turned part’s cuts are made in. Its ends are the planes square across a line whose outer edge
is made of circles about the line and that no cut stands on: every face an end meets in a concave edge turns about
the line too, as the thin end of a shaft rises from its shoulder. The part reads as turned when the faces turning about one line hold at least 35%
of its area (min_turned_share), or at least 75% together with its ends (min_turned_with_ends_share): a disc, a
washer or a flange is mostly ends. The body is then:
every cylinder, cone and torus about that line whose faces close a full turn over one stretch of the line;
every sphere centred on the line;
every end, whatever holes or pockets are sunk into it.
A surface a cut has left open, such as the arc a flat leaves of a shaft, or the root between two key spaces, goes
round less than a full turn: it belongs to the cut that opened it, not to the body. The bar with the ends is high
because a plate carrying one large round boss has the boss’s top as an end too, and it is no turned part. A part
with no turned body gives None, so the result can be passed on as stock_faces as it comes: omitted, the stock is
the one the reader finds for the part.
The body is what the feature readers take as stock. Read on its own, a turned part is measured against the stock the reader finds for it, and a step in its profile looks like a cut: the shoulder of a stepped shaft is read as a step, its ring groove as a cut of unknown kind. Given the body, they are what the lathe made, and only the milled cuts are left to read.
The shaft below is turned about Z: radius 20 for its first 40, with a ring groove 3 deep from 30 to 34, then a shoulder down to radius 10 up to 70.
from volmdlr.shapes import Solid
from volmdlr_tools.features.extractors.interacting_features import InteractingFeatureExtractor
from volmdlr_tools.features.part_reading import PartReading
from volmdlr_tools.graph.faces import AttributedAdjacencyGraph
from volmdlr_tools.reverse_engineering.techniques.turns import turned_body_faces
def read(path):
"""Return the part's graph, its turned body and the cuts read against that body."""
solid = Solid.from_brep(path)
aag = AttributedAdjacencyGraph(solid, allow_smooth=False)
aag.calculate_faces_angles()
body = turned_body_faces(PartReading(solid))
extractor = InteractingFeatureExtractor(aag, stock_faces=body)
extractor.perform()
return aag, body, extractor.result
aag, body, cuts = read("data/brep/turned_parts/stepped_shaft.brep")
print(len(body), aag.face_count, cuts)
# 9 9 []
alone = InteractingFeatureExtractor(aag)
alone.perform()
print(sorted(feature.feature_type.name for feature in alone.result))
# ['STEP', 'UNKNOWN']

The stepped shaft read twice. Left, on its own: the shoulder and the ring groove are read as cuts (orange), the rest
is the stock found for it (sand). Right, with stock_faces=turned_body_faces(PartReading(solid)): all nine faces are the turned
body (blue) and nothing is read as a cut.
Mill a keyway along the thin end and drill a radial hole into the thick end, and the body keeps the nine turned faces while the two cuts are read on it. A flat milled along the whole thin end leaves its cylinder an arc: that arc is no longer the body’s, and the flat is read as a step with it and the shoulder it stops on.
The keyway is 4 wide and 3 deep, from 45 to 65 along the thin end; the radial hole, at 15, has radius 3 and is 8 deep. The flat is cut 3 deep into the thin end, along its whole length.
aag, body, cuts = read("data/brep/turned_parts/keyed_shaft.brep")
print(len(body), aag.face_count, sorted(cut.feature_type.name for cut in cuts))
# 9 16 ['BLIND_HOLE', 'POCKET']
aag, body, cuts = read("data/brep/turned_parts/flatted_shaft.brep")
(flat,) = cuts
print(len(body), aag.face_count, flat.feature_type.name)
# 6 10 BLIND_STEP
print(sorted(aag.graph.nodes[face]["surface_type"] for face in flat.nodes))
# ['CylindricalSurface', 'Plane', 'Plane']

Right, the keyed shaft: the turned body in blue, the keyway and the radial hole in orange. Left, the flatted shaft: the flat, the arc it leaves of the thin end and the shoulder it stops on are the step (orange). The end face it runs across no longer has an outer edge of circles alone, so it is not the body’s either (sand).
The same body can be handed to the whole defeaturing pipeline: see Telling the pipeline the body.
One revolution from a part reading#
recognise_revolution(reading), in volmdlr_tools.reverse_engineering.techniques.revolution, reads one revolution
straight off the part’s PartReading, without reading its features. It cuts the part by several planes through an
axis and keeps the outline they all agree on: that is the profile turned to make the body. What only some of the
planes show, such as a keyway or a flat, is an interruption; it does not stop the reading, as long as most of
the outline turns.
It returns a Revolution, the same record as turned.revolution above, or None when the part has no axis or too
little of its outline turns. Without an axis it tries the part’s strongest axes and keeps the one about which the
longest outline turns; pass axis as a (point, direction) pair to read about a line of your own.
The shaft below is turned about Z: radius 12 for its first 20, then a shoulder rounded to radius 1.5 down to radius 7
up to 50. A keyway 3 wide and 2 deep is milled along the thin end, from 30 to 46
(download shouldered_shaft_with_keyway.step,
in millimetres):
from volmdlr.model import VolumeModel
from volmdlr_tools.features.part_reading import PartReading
from volmdlr_tools.reverse_engineering.techniques.revolution import recognise_revolution
solid = VolumeModel.from_step("shouldered_shaft_with_keyway.step", reading_unit="MM").primitives[0]
revolution = recognise_revolution(PartReading(solid))
print(revolution.axis_direction, revolution.axial_range)
# (0.0, 0.0, 1.0) (0.0, 50.0)
print([(chain.closed, [piece.kind for piece in chain.primitives]) for chain in revolution.chains])
# [(True, ['line', 'line', 'line', 'arc', 'line', 'line', 'line'])]
print(revolution.revolved_share, revolution.unexplained_faces, round(revolution.explained_area_share, 3))
# 1.0 (6, 7, 8, 9, 10) 0.969

The faces that lie on the turned profile in sand, and the five faces of the keyway, which no turn explains, in orange.
The profile is one closed chain in (t, r): the end of the thick part, its side, the shoulder and its round, the side
of the thin part, its end, and the line along the axis that closes it. The planes that cut through the keyway see
it as interruptions, but the outline the planes agree on turns whole. The five faces of the keyway lie on no turn of
the profile, so they are unexplained_faces, and the profile accounts for 96.9% of the part’s area.
A Revolution gives:
Member |
Description |
|---|---|
|
A point of the axis, level with where the part starts along it, and its unit direction |
|
The profile in |
|
Where the turned stretches of the outline start and end along the axis |
|
The share of the outline that turns |
|
The pieces of outline some planes show and the profile does not, each with the |
|
The faces that lie on no turn of the profile, and the share of the part’s area that does |
|
Where the turn starts and how far it sweeps, in radians; a whole turn is |
It raises ValueError when fewer than two cutting planes are asked for, and SectionError when the part cannot be
cut by a plane through the axis given.
See Also#
Gears - Gear recognition
Swept Shapes - Swept shape recognition
AAG (Attributed Adjacency Graph) - Understanding the graph representation
See Also#
Gears - Gear recognition
Swept Shapes - Swept shape recognition