Recognition Document#

One answer for a part: its features, and what every face of it is.

Note

Prerequisites: Attributed Adjacency Graph (AAG)

Recognition Document#

recognise_features(shape) reads a part’s features and returns one recognition document. The document lists the part’s single features, and it gives every face of the part one status. A face can be in a feature, in the body, refused, or unexplained. A reading that explains half the part therefore never looks like one that explains all of it.

FeatureProcessor.recognise() gives the same document and keeps it on the processor, as processor.recognition_document, beside the other extractions.

Four parts with every face coloured by its status: in a feature in blue, in the body in grey, unexplained in red

From left to right:

  • A flanged hub with four bolt holes. It is turned, so the faces of its profile are one revolution and the holes stand on it. Every face is explained.

  • A plate with a slotted boss. The boss’s reading is refused, since its faces bound the slot; the faces of its top that no other reading takes are the boss’s profile extruded from the plate.

  • A block with a pocket, a hole through the pocket floor and a rounded rim. Every face is explained.

  • A shaft with a flat milled along it. The shaft is turned, and nothing reads the flat: it is unexplained.


Quick Start#

A block 60 by 40 and 20 high, with a pocket 30 by 20 and 8 deep in its top, a hole of radius 3 down through the pocket floor, and the pocket’s rim rounded with a radius of 1.5 (download pocketed_block.step, in millimetres):

from volmdlr.model import VolumeModel

from volmdlr_tools.features import recognise_features

block = VolumeModel.from_step("pocketed_block.step", reading_unit="MM").primitives[0]
document = recognise_features(block)
print(sorted(record.kind for record in document.records))
# ['blend', 'blend', 'blend', 'blend', 'hole', 'pocket']
print(document.counts())
# {'feature': 10, 'body': 6, 'refused': 0, 'unexplained': 0}

The pocket’s four walls and floor, the hole and the four rounds of the rim are features. The six faces of the block the pocket and hole were cut from are its body.


RecognitionDocument#

Member

Description

records

The part’s single features, as FeatureRecord

face_account

One FaceStatus for every face of the part, face i at index i

refusals

The readings set aside, each with the faces it covered and why. A refusal stays listed even when another reading keeps its faces

counts()

How many faces have each status

The document checks itself when it is built. Every face a record holds must be accounted to that record, every status must name a record or a refusal the document has, and every record’s parents must be records of the document and lead down to a record with none. A document that does not add up raises a FeatureRecognitionError.

FeatureRecord#

Member

Description

kind

What the feature is: "hole", "pocket", "slot", "step", "groove", "cut", "boss", "addition", "blend", "chamfer", "revolution" for the profile a turned part is turned from, "extrusion" for a profile extruded along a direction, straight or drafted, or "drafted_extrusion" for a body extruded with a draft, read with body=True; "wall", "pipe", "loft" and "sweep" are the bodies of a wall of constant thickness, a bent pipe, a lofted band and a profile swept along a path, read with body=True

sense

"add" for material standing on the part, "subtract" for material taken away, "edge" for a blend or chamfer worked on edges

face_ids

The faces the feature accounts for. No face belongs to two features

base_face_ids

The faces the feature stands on or is cut into, when they were read

parents

The records this feature was made on or cut into: a hole in a pocket floor names the pocket, a hole drilled in a turned part names its revolution. A parent may come after its child in records: a body read again by the advanced readers takes the place of the records it replaces, after them

readers

The readers whose readings the feature merges

origin

Which readers the record comes from: "simple" for the simple readers, "advanced" for the bodies read again in the regions the others leave

stage

When the operation comes in the making of the part: "body" for the body the features are made on, which only the body reading of body=True gives; "feature" for a feature; "finishing" for the work done on edges last, which every record worked on edges is

Sides and ends#

Every face a record holds is a side of its feature or an end that closes it. record.end_face_ids holds the ends, and record.role_of(face) answers "end" for them and "side" for every other face the record holds. It answers None for a face the record does not hold, and for every face of a blend or a chamfer, which are worked on edges and have no sides or ends. The floor of a pocket, the bottom of a blind hole and the top of a boss are ends, and so are the caps of an extruded body. A part turned less than a whole turn ends in the flat faces through its axis, where the turn starts and stops, and a part turned whole has no end. A feature that goes right through has no end.

The pocket of the block above, and the hole through its floor:

for record in document.records:
    if record.kind in {"pocket", "hole"}:
        print(record.kind, [(face, record.role_of(face)) for face in sorted(record.face_ids)])
# pocket [(9, 'side'), (10, 'side'), (11, 'side'), (12, 'side'), (14, 'end')]
# hole [(15, 'side')]

The pocket has four walls and a floor. The hole goes through the floor, so it has no end.

The pocketed block read with body=True, each record's ends in a dark shade and its sides in a light one: the block's caps dark grey and its walls light grey, the pocket floor dark orange and its walls light orange, the hole blue with no end, the rounds of the rim white

The pocketed block read with body=True. Ends are dark, sides light: the block’s two caps and its four walls, the pocket’s floor and its four walls, and the hole, which has only a side. The rounds of the rim (white) have neither.

What a face can be#

Status

Meaning

"feature"

A feature accounts for the face; record names it

"body"

The face belongs to the body the features stand on or are cut into: the stock, including the face the stock ends on opposite its base, or a body record’s faces, which are the faces of the body the part was made from. reason says so

"refused"

A reading covered the face and was set aside, and nothing else accounts for it; refusal names the refusal and reason repeats why

"unexplained"

Nothing accounts for the face

When more than one applies, a feature comes first, then the body, then a refusal. A face of the stock stays the body even when a reading was refused over it: the stock is where the features are taken from, not one more reading competing for the face. The refusal is still listed in refusals.

Turned parts#

A part is read as turned when every one of its faces is either on a profile turned about one axis or on a feature standing on that profile, and the profile carries most of the part’s surface. A turn carrying less, as the round top of a lug standing on a plate, is one feature of a part made otherwise. The faces of the profile are then one "revolution" record, read by "turned". It comes first, and every other feature of the part is made on it, so the part has no body. With body=True the revolution is read as the part’s body instead, as Body and features tells.

Without that reading, the feature readers take a turned part apart: a hub becomes a boss on a step, a bore becomes a hole or a pocket. Each such reading is set aside, and its refusal says the turned profile keeps its faces. A cut that reaches onto the profile, as a keyway cut into a bore, keeps only its own faces.

A blend or a chamfer worked on an edge of the turn, as a fillet run round the foot of a hub, is not part of the profile: it stays a feature of its own, made on the revolution. Read for its body, with body=True, the part gives that fillet to the revolution instead, when it is turned about the axis of the turn: it rounds a corner of the profile. See Rounds drawn in a profile.

A turned groove or a bore is part of the profile, not a feature of its own, and so is a round drawn in the profile, as the half-round rim of a disc (see below). With body=True the bore and the grooves are features made on the revolution instead, as Body and features tells. A face of a turned part that no record holds, as a flat milled along a shaft, is unexplained: the features standing on a turned profile are taken from the feature readers only.

A hub turned about its axis: a flange of radius 40 and 8 thick, a shank of radius 15 rising to 30, a bore of radius 5 through both, and four bolt holes of radius 3 through the flange on a circle of radius 28 (download flanged_hub.step, in millimetres):

from volmdlr.model import VolumeModel

from volmdlr_tools.features import recognise_features

hub = VolumeModel.from_step("flanged_hub.step", reading_unit="MM").primitives[0]
document = recognise_features(hub)
print(sorted(record.kind for record in document.records))
# ['hole', 'hole', 'hole', 'hole', 'revolution']
print(document.counts())
# {'feature': 10, 'body': 0, 'refused': 0, 'unexplained': 0}

Rounds drawn in a profile#

A round can be applied to an edge after the faces it joins were made, or drawn in the sketch those faces were made from: the round end of a slot, the half-round top of a lug, the corner of a plate drawn as an arc about a hole. Both look alike on the part, and the blend reader reads them all as blends. Where the part tells them apart, a round drawn in a profile is given to what made the faces it joins: to the record holding them, or to the body when they are faces of the body. The blend reading it is taken from is set aside, and its refusal names the kind of feature that keeps the round, or the body; the face account gives the record.

A round whose two faces, extended, would meet at a sharp edge close by, as a rounded corner of a rectangle, could have been drawn either way; without body it stays a blend.

Read for its body, with body=True, the part tells more: the body it was made from is known, and so is the profile of each of its extrusions and revolutions. A round that is a wall of one of them is a rounded corner of that profile, and is drawn in it:

  • A round running along the direction a body was extruded in is a wall of its extrusion, drafted or not. It is the body’s when it rounds a corner of the body’s outline, and the pocket’s when it rounds a corner of a window cut through the body. A round across the extrusion, as along the rim of a cap, is no wall of it.

  • A round turned about the axis of a revolution, as the round of a shaft’s shoulder or of the foot of a hub, is a wall of the revolution, and the revolution’s. A round about any other axis, as the rim of a hole off the axis, is not.

A round goes with the whole run it belongs to, the rounds that carry on one another tangentially at one radius, since one fillet makes them together. A run that is a wall only in part, as a round down a corner running on round the rim at the top of a block, is one fillet worked on an edge: every round of it stays a blend, and so does a run no single record can keep whole. Rounds meeting across a crease, or at another radius, are runs of their own. Each round given up leaves a refusal naming the profile that keeps it, as for a slot’s round end.

A round that is a wall of a pocket, a slot, a step or a cut is given to that cut, whether or not the part is read with body=True: it is a rounded corner of the outline the cut was made from, and the cut’s profile runs through it. body_wall_rounds=False keeps every such round a blend; given with body=True, it also keeps the rounds of the body’s profiles blends, finishing the body, as before.

Three parts with every face coloured by the feature holding it: a turned hub whose fillet stays a blend on the revolution, a plate whose corner round is the body, a block whose slot keeps its round ends

From left to right:

  • A turned hub with a fillet run round its foot, read without body. The fillet (yellow) stays a blend, made on the revolution.

  • A plate whose corner is drawn as an arc about a hole. The corner round is the body (grey).

  • A block with a slot sunk in its top. The slot’s round ends are the slot’s (orange).

A block 60 by 40 and 20 high with a slot sunk 8 deep in its top, 8 wide and its round ends 20 apart (download slotted_block.step, in millimetres):

from volmdlr.model import VolumeModel

from volmdlr_tools.features import recognise_features

block = VolumeModel.from_step("slotted_block.step", reading_unit="MM").primitives[0]
document = recognise_features(block)
print([(record.kind, len(record.face_ids)) for record in document.records])
# [('pocket', 5)]
for refusal in document.refusals:
    print(refusal.reason)
# the blend reading rounds the profile of the pocket, which keeps its faces
# the blend reading rounds the profile of the pocket, which keeps its faces

Extruded profiles#

A face that no feature reading takes and the body does not have is often a face of the profile the part was extruded from: a wall of a plate’s outline, or a stretch of its top between two steps. When such faces are left, the part is read as slabs stacked along the direction it was built along, each a profile extruded straight or with a draft. A slab holds the faces lying on its walls, carried up and down by their drafts, and the flat faces closing it. The faces of a slab that nothing else accounts for are one "extrusion" record, sense "add", read by "slabs".

The extrusion only explains what was left. A hole, a step or a blend on the slab’s walls keeps its faces, and so does the body. A part whose every face is already explained is not read as slabs at all, and neither is a turned part: a face its revolution leaves, as a flat milled along a shaft, is a feature worked on the turn, though the shaft and its flat are also a profile extruded along the axis.

A plate with two steps cut into its back, every face coloured by the record holding it

A plate extruded along its thickness, with a step cut at each end of its back and two holes through it. The steps (green), the holes (pink) and the rounded corners of its outline (yellow) are features, and the faces of the stock are the body (grey). The stretch of the back between the two steps is no step’s and was not read with the stock: it is the plate’s extrusion (blue).

A plate 40 by 16 with corners of radius 3, extruded 6 thick along X, a step 8 wide and 2 deep cut across each end of its back, and two holes of radius 2 through it (download stepped_plate.step, in millimetres):

from volmdlr.model import VolumeModel

from volmdlr_tools.features import recognise_features

plate = VolumeModel.from_step("stepped_plate.step", reading_unit="MM").primitives[0]
document = recognise_features(plate)
print(sorted(record.kind for record in document.records))
# ['blend', 'blend', 'blend', 'blend', 'extrusion', 'hole', 'hole', 'step', 'step']
print(document.counts())
# {'feature': 11, 'body': 5, 'refused': 0, 'unexplained': 0}

The part is read as slabs along the one direction it was most built along, for a bounded time. When that time runs out, when the part cannot be cut along it, or when no face of it can lie on a slab along it, a refusal says so, with no faces of its own.

Body and features#

A part is a body and the features made on it: a hub is turned from its profile, then drilled; a block is pulled from its outline, then pocketed. recognise_features(shape, body=True) reads the part that way, as one construction tree:

  • The body comes first. Each extrusion, drafted extrusion or revolution the part was made from is a record of its own, with stage "body" and readers ("body",). A body made on another names it in parents.

  • The features come next, with stage "feature": the holes, pockets, slots and bosses made on the body, each naming the body it stands on in parents.

  • The work done on edges comes last, with stage "finishing".

Every face of the part still has one status: a body record’s faces are "body", a feature’s are "feature".

A turned hub and a pocketed block read for their body

Left, the flanged hub above: its revolution is the body (grey), and the bore and the four bolt holes drilled in the flange are features (orange). Right, the pocketed block of the quick start: the block extruded from its outline is the body, the pocket and the hole in its floor are cuts, and the rounds along the pocket’s rim are finishing (yellow). A boss would be blue, and a refused face red.

A reading of the feature readers that lies on faces of the body, as a boss made of the hub’s shank or a step made of its shoulder, is the body read twice. It is set aside, its faces stay the body’s, and its refusal stays in refusals, saying it lies on the body the part was made from:

hub = VolumeModel.from_step("flanged_hub.step", reading_unit="MM").primitives[0]
document = recognise_features(hub, body=True)
print([record.kind for record in document.records if record.stage == "body"])
# ['revolution']
for refusal in document.refusals:
    print(refusal.reader, refusal.reason)
# depression_protrusion the boss reading lies on the body the part was made from
# interacting the step reading lies on the body the part was made from
print(document.counts())
# {'feature': 5, 'body': 5, 'refused': 0, 'unexplained': 0}

Which readings the body takes:

  • A cut is the body’s when every face it has, but for the faces a blend or a chamfer holds, is a face of the body.

  • A hole or a groove stays a feature on a revolution all the same: a bore holding the axis, or a groove turned into the profile, is more often worked after the turn than drawn in its profile.

  • A cut stays a cut on a part milled from a block: when the flat faces of an extruded part still cover most of the sides of the box holding it, squared to the extrusion, a step or a slot through it is a cut, not a notch drawn in the outline; a part read with the "supporting_plane" stock convention is always read as milled from a block.

  • A boss is the body’s when the body holds more than half of its area. A boss standing off a revolution, as a rib along a hub, stays a boss and keeps only its own faces.

  • A chamfer is never the body’s. A blend is the body’s only when it is a round drawn in the body’s profile, as Rounds drawn in a profile tells; a blend worked on an edge is finishing.

A turned part’s revolution holds the faces its profile sweeps but its bore: the bore, stepped or blind, is a hole in the revolution, as are holes off the axis, as a bolt circle. A wall facing the axis round an outer face of the turn, as the inside of a wheel’s rim round its hub, is no bore and stays the revolution’s. A cut that reaches onto the revolution gives up the faces it reads there and keeps what lies off it, with a refusal for the faces it gave up. A keyway cut along the bore is a "slot" standing on the bore’s hole; a cross hole meeting the bore stays a hole standing on the revolution and on the bore. A flat milled across a whole turn, as the flats cut across the rim of a turned disc, is a "cut" made on the revolution, one for each plane, whose readers are ("trims",): the whole part lies on one side of the plane and the turn’s profile reaches past it. The cut runs right through the turn, so it has no end face, and its base_face_ids are the faces of the revolution it meets. A feature worked on the revolution that no reader reads, as a hole a feature reader leaves out, is refused, saying so. The faces the revolution does not hold, but for round holes drilled in it, are handed back: an extruded profile may read them, as a flange extruded on a turned hub, and one no profile reads is refused, its reason saying the revolution hands the face back and no extruded profile reads it. So is a face of a body extruded on the revolution, as a window wall of a flange, that no profile reads.

Only the body at the root of the tree makes the part a turned part: a hub turned on an extruded plate does not make the plate turned, and the plate’s faces are read as any extruded part’s.

When there is no body to read, the part is read as it is without body:

  • when stock_faces is given, as the stock is then the body;

  • when no extrusion or revolution is read from the part, as a sphere or a free-form shell;

  • when the body reading fails. A failure leaves one refusal over the whole part, with no faces, whose reader is "body" and whose reason says the part is read without its body. In strict mode the failure is raised as a FeatureRecognitionError instead.

body is the only switch that turns the body reading on or off: no family does. Without it, the default, the document is the one the readers give alone. body_wall_rounds, true by default, says whether the rounds drawn in the profiles of the body, when it is read, and of the pockets, slots, steps and cuts, with or without it, are given to them; false keeps them blends.

Regions read again#

Some parts are not made of extrusions and revolutions: a moulded tray is a wall of constant thickness, a hose is a profile swept along a bent path, a handle a profile that changes along a spline. The simple readings explain such a part badly: they read the cavity of a tray as a pocket, or leave faces unexplained. With body=True, the faces the simple readings leave unexplained, refuse, or read suspiciously are gathered into regions, and each region is read again by the readers of these bodies. A reading is used on a region only when the region holds at least half of the faces the reading contests, which are its faces other than those of the body, of the stock and of the work done on edges, so that a reading lying mostly elsewhere does not take the region. Faces worked on edges are never taken. A swept profile is read on each region alone, from the region and the faces next to it, so that every face it is carried along must lie in the region. A body found this way is a record of its own, of kind "wall", "pipe", "loft" or "sweep", with stage "body" and origin "advanced", and the readings of the region that lie on it are set aside, as for any other body; a cut on a part cut from a block is never one of them.

A drafted tray read without and with the regions read again

A drafted tray, hollowed and open at the top. Left, read without the regions read again: the extruded outline is the body (grey) and the cavity a pocket (orange). Right, read with them: the whole tray is one wall (grey).

tray = VolumeModel.from_step("drafted_tray.step", reading_unit="MM").primitives[0]
print([(record.kind, record.origin) for record in recognise_features(tray).records])
# [('pocket', 'simple')]
document = recognise_features(tray, body=True)
for record in document.records:
    print(record.kind, record.stage, record.origin, record.readers)
# wall body advanced ('walls',)
for refusal in document.refusals:
    print(refusal.reason)
# the pocket reading lies on the wall body
# the drafted_extrusion body's faces lie on the wall body
print(document.counts())
# {'feature': 0, 'body': 11, 'refused': 0, 'unexplained': 0}

Each reader is tried only on the regions it suits. Walls are looked for where the part shows moulding, a spline face the body does not explain or a body extruded with a draft: a thin-walled part of plain flat and round faces, as a machined tube, is never read as a wall. Pipes are looked for where a region holds a toroidal face that is no blend, lofts where it holds a spline face, and sweeps where the body reading found a face a profile carried along a path makes; a machined part has none of these, and no reader is run on it.

A reader tried on a region and not used there leaves a refusal naming it, over the faces of the region its readings held: a reading that lies mostly outside the region, one that the records of the region would leave no face, or one taken in another region. A region that no reading reaches stays as it was, its faces unexplained, with no refusal. A reader that fails, or runs out of time, leaves one refusal naming it and over no face. The readers stop at the deadline, like the others: once it has passed, no region is read and one refusal over the part says the time ran out. A failure to read the regions at all leaves one refusal over the part, and raises a FeatureRecognitionError in strict mode.

The construction tree#

document.tree() lays the records out as a tree, for when the construction matters more than the flat list: the bodies at the roots, the features made on each below it, and the work done on edges as the leaves. It is built from the records’ parents and stage alone and keeps nothing of its own.

A turned hub and a pocketed block coloured by their place in the tree: bodies grey, features made on the body orange, features made on those blue, finishing yellow

Left, a flanged hub with a keyed bore: the revolution (grey), the bore, a hole made on it (orange), and the keyway cut along the bore, a slot made on that hole (blue). Right, the pocketed block of the quick start: the extrusion (grey), the pocket cut into it (orange), the hole through the pocket floor (blue) and the pocket’s rounded rim, finishing (yellow).

A keyed hub, a flanged hub of radius 40 with a bore of radius 8 and a keyway 4 by 4 cut along it (download keyed_hub.step, in millimetres), the pocketed block, and the drafted tray of Regions read again, as trees:

from volmdlr.model import VolumeModel

from volmdlr_tools.features import recognise_features


def show(document, nodes, depth=0):
    for node in nodes:
        record = document.records[node.record]
        print("  " * depth + f"{record.kind} ({record.stage})")
        show(document, node.children, depth + 1)


block = VolumeModel.from_step("pocketed_block.step", reading_unit="MM").primitives[0]
document = recognise_features(block, body=True)
show(document, document.tree())
# extrusion (body)
#   pocket (feature)
#     hole (feature)
#     blend (finishing)
#     blend (finishing)
#     blend (finishing)
#     blend (finishing)

hub = VolumeModel.from_step("keyed_hub.step", reading_unit="MM").primitives[0]
document = recognise_features(hub, body=True)
show(document, document.tree())
# revolution (body)
#   hole (feature)
#     slot (feature)

tray = VolumeModel.from_step("drafted_tray.step", reading_unit="MM").primitives[0]
document = recognise_features(tray, body=True)
show(document, document.tree())
# wall (body)

tree() returns the roots as a tuple of ConstructionNode:

Member

Description

record

The index of the record in the document’s records

children

The records made on this one, as ConstructionNode

A node holds an index, not a copy of the record: document.records[node.record] is the record, whatever it holds. The record tells where the reading came from: its origin is "advanced" for the wall of a moulded tray, a body read again from the regions the simple readings leave, as Regions read again tells, and "simple" for the rest.

How the records are laid out:

  • The roots are the records made on nothing: the bodies first, then the features, then the work done on edges. A part read without body=True has no body record, so the features made on nothing are its roots.

  • Under each record come the records made on it, in the same order, and records of one stage in the order of records. A blend run along the rim of a pocket is under the pocket, a blend worked on an edge of a block’s outline, as along the rim of its top, under the body.

  • A record with several parents is under the deepest of them: the one the longest chain of parents leads to, and the one that comes first in records when they are as deep. A keyway cut along a bore that is a hole of its own, as in a block, is under the hole, and the hole under the body. Every record is in the tree once.

  • A tree is a partial order only. A record always comes after the record it hangs under, and the work done on edges after its siblings, but nothing says which of two siblings is made first, or that all the holes of a part are made before its pockets. The order to build a part in is not the tree’s to say.

  • A document whose record names a parent it does not have, or whose parents loop back on themselves, is refused when it is built, with a FeatureRecognitionError.

Readers, families and strict mode#

The document is read by several readers, each reading the part one way and knowing nothing of the others: the cut reader, the loop reader, the readers of additions, blends, chamfers and trims, and the readers of the turned and extruded profiles. Each runs on its own. One that fails gives a refusal over the whole part, naming the reader and its message, and the others’ records are still given; one that runs out of time keeps what it read and gives a refusal saying the time ran out. A refusal’s reader names the reader it came from.

Reader

Family

What it reads

"interacting"

"cuts"

The cuts taken from the stock: holes, pockets, slots, steps and grooves, read from the faces the stock does not have

"depression_protrusion"

"cuts", "bosses"

Holes, pockets and bosses, read from the loops of edges bounding them

"split_adjacency"

"additions"

Additions running off an edge, read from the faces they split apart

"blend"

"blends"

Blends

"chamfer"

"chamfers"

Chamfers

"trims"

"trims"

The planes the part may have been cut back to

"turned"

"profiles"

The profile a turned part is turned from, as one "revolution" record

"slabs"

"profiles"

The profiles a part is extruded from, as "extrusion" records

A record’s readers holds these names, and so does a refusal’s reader.

FaceRefusal#

Each entry of refusals is a FaceRefusal, from volmdlr_tools.refusals:

Member

Description

reason

Why the reading was set aside, or why the faces could not be read

face_ids

The faces the refusal is about; empty when it is about the whole part, as for a reader that failed

area

The area of those faces, when it is known; None otherwise

reader

The reader whose reading was set aside. When the reading merges several readers’ readings, their names are joined by "/", as "interacting/depression_protrusion". Empty when it is not said

out_of_time

Whether the faces were not read because the reader’s time ran out, rather than because they do not fit

Every reader is handed the same part: its reading, read once, with its graphs, its blends and its tolerances, and what the caller knows of it, such as the stock its cuts are taken from. No reader reads the part again, so they all agree on which faces are blends and how close is close.

Ask for only the families you need with families. A reader runs when one of its families is asked for:

Family

What it reads

"cuts"

Holes, pockets, slots, steps, grooves and other cuts

"bosses"

Bosses standing on the part

"additions"

Additions running off an edge

"blends"

Blends

"chamfers"

Chamfers

"trims"

The planes the part may have been cut back to

"profiles"

The profile a turned part is turned from, and the profiles a part is extruded from

block = VolumeModel.from_step("pocketed_block.step", reading_unit="MM").primitives[0]
document = recognise_features(block, families=["blends"])
print(sorted(record.kind for record in document.records))
# ['blend', 'blend', 'blend', 'blend']

With strict=True, a reader’s exception is raised as a FeatureRecognitionError instead of recorded, so that tests and debugging see the real error.

A caller that reads the same part for several purposes reads it once, as a PartReading, and hands it to recognise_features in place of the shape: the document is the same, and the part is not read again. With deadline, a moment as time.perf_counter gives it, not a duration (time.perf_counter() + 30), a reader not yet run when it passes, and the body reading with body=True, give no readings and leave a refusal over the whole part saying their time ran out, so no reading is lost without saying so. What was read before the deadline is in the document. Without a deadline, each reader keeps to its own time alone.

When two readings claim the same faces#

Two readers may read the same faces: the cut reader and the loop reader both read a pocket, a boss’s side may also read as a cut. The choice between them is made once, in one place, in this order: the bosses the loops read, then the cuts in the order they were read, then the depressions the loops read, merged into the cut they repeat, then the additions, blends and chamfers where nothing else reads their faces. An inside bevel, a chamfer filling the square corner where a pocket wall meets its floor or in the inside corner of a step, is a chamfer record: the cut beside it keeps the rest of its faces, as it does beside a round. A hole keeps the bevel at its flat bottom, which it is drilled with. A reading set aside, in whole or in part, stays in refusals: its reader names where it came from, and its reason names the feature that kept its faces, such as Pocket shares these faces with the pocket 0 read by interacting/depression_protrusion, read before it, which keeps them.

Limits#

  • The document holds the features the feature model reads: cuts, holes, pockets, slots, steps and grooves, bosses and additions, blends and chamfers, the profile of a turned part, and the extruded profiles. Readings of how a part was built from its other sections, such as sweeps, come later.

  • An unexplained face is a gap in what is read today, not a fault in the part.

  • A part is read as turned only when that reading explains every face and the turned profile carries most of the part’s surface. A turned part with a feature it cannot read, as a keyway along a bore, is read by the feature readers alone.

recognise_features reads one solid. It raises a ShapeTypeError for a shape holding several solids, or faces beside its solid. Give stock_faces when you have read the body the cuts are taken from yourself; the part is then not read as turned. stock_convention says what the stock is when you do not give it: "convex_hull", the default (DEFAULT_STOCK_CONVENTION), reads it as the bar the part was machined from, a block, a round or a polygonal bar alike: a face is stock wherever the whole part lies behind it. "extruded_profile" reads it as the profile the part was extruded from, the former default, and "supporting_plane" as the block the part was cut from. Only "convex_hull" reads the cuts through the part’s outline, from one face of the bar to the opposite one, as outline cuts (FeatureType.OUTLINE_CUT, collected by FeatureProcessor.outline_cuts). Under it, a faced top, a flat face below the hull that every neighbour meets at a sharp convex edge (the island of a sunken groove, a block top under a boss rising past it), comes out as an unnamed FeatureType.UNKNOWN feature of its own: the material above it was removed from the bar.

See Also#