14  Appearance: Colours and Layers

Nine records to make a pin orange. Why the colour is attached to the geometry from the outside, how a colour reaches a single face, and where the layers went.

The clamp assembly was exported with the bracket grey and the pins orange. Both colours are in the file, and neither is anywhere near the geometry it colours. Here is the pin’s:

#318 = MECHANICAL_DESIGN_GEOMETRIC_PRESENTATION_REPRESENTATION('',(#319),#302);
#319 = STYLED_ITEM('color',(#320),#249);
#320 = PRESENTATION_STYLE_ASSIGNMENT((#321));
#321 = SURFACE_STYLE_USAGE(.BOTH.,#322);
#322 = SURFACE_SIDE_STYLE('',(#323));
#323 = SURFACE_STYLE_FILL_AREA(#324);
#324 = FILL_AREA_STYLE('',(#325));
#325 = FILL_AREA_STYLE_COLOUR('',#326);
#326 = COLOUR_RGB('',0.800000010877,0.500000003429,0.199999998682);
Referred to above: 58 records from clamp.step
#249 = MANIFOLD_SOLID_BREP('',#250);
#250 = CLOSED_SHELL('',(#251,#284,#293));
#251 = ADVANCED_FACE('',(#252),#279,.T.);
#252 = FACE_BOUND('',#253,.F.);
#253 = EDGE_LOOP('',(#254,#264,#271,#272));
#254 = ORIENTED_EDGE('',*,*,#255,.T.);
#255 = EDGE_CURVE('',#256,#258,#260,.T.);
#256 = VERTEX_POINT('',#257);
#257 = CARTESIAN_POINT('',(3.,0.,0.));
#258 = VERTEX_POINT('',#259);
#259 = CARTESIAN_POINT('',(3.,0.,30.));
#260 = LINE('',#261,#262);
#261 = CARTESIAN_POINT('',(3.,0.,0.));
#262 = VECTOR('',#263,1.);
#263 = DIRECTION('',(0.,0.,1.));
#264 = ORIENTED_EDGE('',*,*,#265,.T.);
#265 = EDGE_CURVE('',#258,#258,#266,.T.);
#266 = CIRCLE('',#267,3.);
#267 = AXIS2_PLACEMENT_3D('',#268,#269,#270);
#268 = CARTESIAN_POINT('',(0.,0.,30.));
#269 = DIRECTION('',(0.,0.,1.));
#270 = DIRECTION('',(1.,0.,0.));
#271 = ORIENTED_EDGE('',*,*,#255,.F.);
#272 = ORIENTED_EDGE('',*,*,#273,.F.);
#273 = EDGE_CURVE('',#256,#256,#274,.T.);
#274 = CIRCLE('',#275,3.);
#275 = AXIS2_PLACEMENT_3D('',#276,#277,#278);
#276 = CARTESIAN_POINT('',(0.,0.,0.));
#277 = DIRECTION('',(0.,0.,1.));
#278 = DIRECTION('',(1.,0.,0.));
#279 = CYLINDRICAL_SURFACE('',#280,3.);
#280 = AXIS2_PLACEMENT_3D('',#281,#282,#283);
#281 = CARTESIAN_POINT('',(0.,0.,0.));
#282 = DIRECTION('',(-0.,-0.,-1.));
#283 = DIRECTION('',(1.,0.,0.));
#284 = ADVANCED_FACE('',(#285),#288,.F.);
#285 = FACE_BOUND('',#286,.F.);
#286 = EDGE_LOOP('',(#287));
#287 = ORIENTED_EDGE('',*,*,#273,.T.);
#288 = PLANE('',#289);
#289 = AXIS2_PLACEMENT_3D('',#290,#291,#292);
#290 = CARTESIAN_POINT('',(-1.709300165674E-16,-8.51133553645E-18,0.));
#291 = DIRECTION('',(0.,0.,1.));
#292 = DIRECTION('',(1.,0.,-0.));
#293 = ADVANCED_FACE('',(#294),#297,.T.);
#294 = FACE_BOUND('',#295,.T.);
#295 = EDGE_LOOP('',(#296));
#296 = ORIENTED_EDGE('',*,*,#265,.T.);
#297 = PLANE('',#298);
#298 = AXIS2_PLACEMENT_3D('',#299,#300,#301);
#299 = CARTESIAN_POINT('',(-1.709300165674E-16,-8.51133553645E-18,30.));
#300 = DIRECTION('',(0.,0.,1.));
#301 = DIRECTION('',(1.,0.,-0.));
#302 = ( GEOMETRIC_REPRESENTATION_CONTEXT(3) 
GLOBAL_UNCERTAINTY_ASSIGNED_CONTEXT((#306)) GLOBAL_UNIT_ASSIGNED_CONTEXT
((#303,#304,#305)) REPRESENTATION_CONTEXT('Context #1',
  '3D Context with UNIT and UNCERTAINTY') );
#303 = ( LENGTH_UNIT() NAMED_UNIT(*) SI_UNIT(.MILLI.,.METRE.) );
#304 = ( NAMED_UNIT(*) PLANE_ANGLE_UNIT() SI_UNIT($,.RADIAN.) );
#305 = ( NAMED_UNIT(*) SI_UNIT($,.STERADIAN.) SOLID_ANGLE_UNIT() );
#306 = UNCERTAINTY_MEASURE_WITH_UNIT(LENGTH_MEASURE(1.E-07),#303,
  'distance_accuracy_value','confusion accuracy');

The complete file

Nine records, of which one carries the colour and one names the thing being coloured. The rest is Part 46 — visual presentation — doing what the integrated resources always do: expressing a simple idea in terms general enough to cover every kind of presentation anyone might want.

14.1 Reading the chain

From the bottom:

  • #326 COLOUR_RGB — red 0.8, green 0.5, blue 0.2. Components are reals from 0 to 1. The name is empty. (The values are not quite 0.8, 0.5 and 0.2 because the exporter converts colours to a linear working space and back in single precision; deviations of this size carry no meaning.)
  • #325 FILL_AREA_STYLE_COLOUR — a colour used for filling areas. The alternative is a hatch pattern or a tile.
  • #324 FILL_AREA_STYLE — a set of fill styles (here, one). Fill styles are what a face gets; curve styles are what an edge gets.
  • #323 SURFACE_STYLE_FILL_AREA — the fill style applied as a surface style element. Other elements exist for boundaries, silhouettes, parameter lines, rendering.
  • #322 SURFACE_SIDE_STYLE — a set of surface style elements for one side of a surface.
  • #321 SURFACE_STYLE_USAGE — that side style applied to .BOTH. sides of the surface (or .POSITIVE. or .NEGATIVE.).
  • #320 PRESENTATION_STYLE_ASSIGNMENT — a set of styles (here, one surface style usage) to be assigned together.
  • #319 STYLED_ITEM — the assignment. name is 'color', styles is (#320), and item is #249: the pin’s MANIFOLD_SOLID_BREP. This is the record that connects appearance to geometry, and it does so by pointing at the solid — the solid does not know it has a colour.
  • #318 MECHANICAL_DESIGN_GEOMETRIC_PRESENTATION_REPRESENTATION — a representation whose items are styled items, in the same geometric context as the geometry it decorates (#302). Its job is to be a container a reader can look for. There are two such containers in practice, this one and DRAUGHTING_MODEL, and a file with PMI in it will use the latter: find every representation of either type, and you have found every colour in the file.

Every surface colour in every AP214 or AP242 file follows this chain. The middle six records are almost always exactly these, differing only in instance numbers, and once you have read one you can skim the rest. What varies is the two ends: which colour, and which item.

14.2 What gets coloured

STYLED_ITEM.item can point at any representation item. In practice:

A solid. As here. The whole body takes the colour. This is what most exporters write for a part with a single body colour, and it is what a viewer applies by default to every face of the solid.

A face. STYLED_ITEM('',(#s),#88) with #88 an ADVANCED_FACE colours one face. Files with per-face colours have one styled item per face, and they can number in the thousands. Style is inherited downwards, so a face takes the body’s colour unless something says otherwise, and the thing that says otherwise is OVER_RIDING_STYLED_ITEM — a Part 46 subtype of STYLED_ITEM with an extra attribute pointing at the styled item it overrides. The recommended practice requires it for a per-face colour; a bare second styled item on the face is not enough.

An edge or a curve. Via a CURVE_STYLE instead of a surface style: CURVE_STYLE('',#font,POSITIVE_LENGTH_MEASURE(0.1),#colour) — a line font, a width (a wrapped measure, as Chapter 4 predicted), a colour. Edge colours appear in wireframe exports and in PMI annotation geometry.

A mapped item or a whole representation, so that an assembly component can be coloured as a unit without touching the child’s geometry. Less common.

The pin’s colour is on the pin’s solid, #249, which belongs to the pin’s product. Both occurrences of the pin are therefore orange, because both are instances of the same product and there is one solid. Had the CAD system coloured pin-2 differently, the exporter would have written a CONTEXT_DEPENDENT_OVER_RIDING_STYLED_ITEM, whose style_context is the top-down list of representation relationships naming the one occurrence. It is in all three schemas, and “instance colour” is still one of the features most often lost in exchange, because many exporters and readers ignore it.

14.3 Named colours

COLOUR_RGB is one of two colour entities. The other:

#340 = DRAUGHTING_PRE_DEFINED_COLOUR('red');

A DRAUGHTING_PRE_DEFINED_COLOUR has only a name, from a fixed list: 'red', 'green', 'blue', 'yellow', 'magenta', 'cyan', 'black', 'white'. It stands in for the RGB triple wherever one is expected. It is inherited from the drawing-exchange parts of the standard, where line colours were symbolic, and is what a few exporters write for their default palette. The schema gives the eight names no RGB values, but the CAx-IF recommended practice fixes them as the pure corners of the colour cube, plus black and white.

14.4 Layers

CAD systems group entities onto named layers, and Part 46 carries them:

#350 = PRESENTATION_LAYER_ASSIGNMENT('Pins','locating pins',(#249));
Referred to above: 53 records from clamp.step
#249 = MANIFOLD_SOLID_BREP('',#250);
#250 = CLOSED_SHELL('',(#251,#284,#293));
#251 = ADVANCED_FACE('',(#252),#279,.T.);
#252 = FACE_BOUND('',#253,.F.);
#253 = EDGE_LOOP('',(#254,#264,#271,#272));
#254 = ORIENTED_EDGE('',*,*,#255,.T.);
#255 = EDGE_CURVE('',#256,#258,#260,.T.);
#256 = VERTEX_POINT('',#257);
#257 = CARTESIAN_POINT('',(3.,0.,0.));
#258 = VERTEX_POINT('',#259);
#259 = CARTESIAN_POINT('',(3.,0.,30.));
#260 = LINE('',#261,#262);
#261 = CARTESIAN_POINT('',(3.,0.,0.));
#262 = VECTOR('',#263,1.);
#263 = DIRECTION('',(0.,0.,1.));
#264 = ORIENTED_EDGE('',*,*,#265,.T.);
#265 = EDGE_CURVE('',#258,#258,#266,.T.);
#266 = CIRCLE('',#267,3.);
#267 = AXIS2_PLACEMENT_3D('',#268,#269,#270);
#268 = CARTESIAN_POINT('',(0.,0.,30.));
#269 = DIRECTION('',(0.,0.,1.));
#270 = DIRECTION('',(1.,0.,0.));
#271 = ORIENTED_EDGE('',*,*,#255,.F.);
#272 = ORIENTED_EDGE('',*,*,#273,.F.);
#273 = EDGE_CURVE('',#256,#256,#274,.T.);
#274 = CIRCLE('',#275,3.);
#275 = AXIS2_PLACEMENT_3D('',#276,#277,#278);
#276 = CARTESIAN_POINT('',(0.,0.,0.));
#277 = DIRECTION('',(0.,0.,1.));
#278 = DIRECTION('',(1.,0.,0.));
#279 = CYLINDRICAL_SURFACE('',#280,3.);
#280 = AXIS2_PLACEMENT_3D('',#281,#282,#283);
#281 = CARTESIAN_POINT('',(0.,0.,0.));
#282 = DIRECTION('',(-0.,-0.,-1.));
#283 = DIRECTION('',(1.,0.,0.));
#284 = ADVANCED_FACE('',(#285),#288,.F.);
#285 = FACE_BOUND('',#286,.F.);
#286 = EDGE_LOOP('',(#287));
#287 = ORIENTED_EDGE('',*,*,#273,.T.);
#288 = PLANE('',#289);
#289 = AXIS2_PLACEMENT_3D('',#290,#291,#292);
#290 = CARTESIAN_POINT('',(-1.709300165674E-16,-8.51133553645E-18,0.));
#291 = DIRECTION('',(0.,0.,1.));
#292 = DIRECTION('',(1.,0.,-0.));
#293 = ADVANCED_FACE('',(#294),#297,.T.);
#294 = FACE_BOUND('',#295,.T.);
#295 = EDGE_LOOP('',(#296));
#296 = ORIENTED_EDGE('',*,*,#265,.T.);
#297 = PLANE('',#298);
#298 = AXIS2_PLACEMENT_3D('',#299,#300,#301);
#299 = CARTESIAN_POINT('',(-1.709300165674E-16,-8.51133553645E-18,30.));
#300 = DIRECTION('',(0.,0.,1.));
#301 = DIRECTION('',(1.,0.,-0.));

The complete file

A name, a description, and a set of the representation items on the layer: here only #249, the pin’s solid, and not the bracket’s solid #41. As always, the layer points at its members; a face does not know its layer. A file’s layers are found by collecting every PRESENTATION_LAYER_ASSIGNMENT and inverting. Layer assignments are far less common in STEP than in native CAD files: many exporters do not write them, and when they do the members are typically solids rather than faces. AP203 first edition has no layer entity at all.

14.5 Visibility

A layer can be switched off, or an item hidden, with INVISIBILITY:

#360 = INVISIBILITY((#319));
Referred to above: 61 records from clamp.step
#249 = MANIFOLD_SOLID_BREP('',#250);
#250 = CLOSED_SHELL('',(#251,#284,#293));
#251 = ADVANCED_FACE('',(#252),#279,.T.);
#252 = FACE_BOUND('',#253,.F.);
#253 = EDGE_LOOP('',(#254,#264,#271,#272));
#254 = ORIENTED_EDGE('',*,*,#255,.T.);
#255 = EDGE_CURVE('',#256,#258,#260,.T.);
#256 = VERTEX_POINT('',#257);
#257 = CARTESIAN_POINT('',(3.,0.,0.));
#258 = VERTEX_POINT('',#259);
#259 = CARTESIAN_POINT('',(3.,0.,30.));
#260 = LINE('',#261,#262);
#261 = CARTESIAN_POINT('',(3.,0.,0.));
#262 = VECTOR('',#263,1.);
#263 = DIRECTION('',(0.,0.,1.));
#264 = ORIENTED_EDGE('',*,*,#265,.T.);
#265 = EDGE_CURVE('',#258,#258,#266,.T.);
#266 = CIRCLE('',#267,3.);
#267 = AXIS2_PLACEMENT_3D('',#268,#269,#270);
#268 = CARTESIAN_POINT('',(0.,0.,30.));
#269 = DIRECTION('',(0.,0.,1.));
#270 = DIRECTION('',(1.,0.,0.));
#271 = ORIENTED_EDGE('',*,*,#255,.F.);
#272 = ORIENTED_EDGE('',*,*,#273,.F.);
#273 = EDGE_CURVE('',#256,#256,#274,.T.);
#274 = CIRCLE('',#275,3.);
#275 = AXIS2_PLACEMENT_3D('',#276,#277,#278);
#276 = CARTESIAN_POINT('',(0.,0.,0.));
#277 = DIRECTION('',(0.,0.,1.));
#278 = DIRECTION('',(1.,0.,0.));
#279 = CYLINDRICAL_SURFACE('',#280,3.);
#280 = AXIS2_PLACEMENT_3D('',#281,#282,#283);
#281 = CARTESIAN_POINT('',(0.,0.,0.));
#282 = DIRECTION('',(-0.,-0.,-1.));
#283 = DIRECTION('',(1.,0.,0.));
#284 = ADVANCED_FACE('',(#285),#288,.F.);
#285 = FACE_BOUND('',#286,.F.);
#286 = EDGE_LOOP('',(#287));
#287 = ORIENTED_EDGE('',*,*,#273,.T.);
#288 = PLANE('',#289);
#289 = AXIS2_PLACEMENT_3D('',#290,#291,#292);
#290 = CARTESIAN_POINT('',(-1.709300165674E-16,-8.51133553645E-18,0.));
#291 = DIRECTION('',(0.,0.,1.));
#292 = DIRECTION('',(1.,0.,-0.));
#293 = ADVANCED_FACE('',(#294),#297,.T.);
#294 = FACE_BOUND('',#295,.T.);
#295 = EDGE_LOOP('',(#296));
#296 = ORIENTED_EDGE('',*,*,#265,.T.);
#297 = PLANE('',#298);
#298 = AXIS2_PLACEMENT_3D('',#299,#300,#301);
#299 = CARTESIAN_POINT('',(-1.709300165674E-16,-8.51133553645E-18,30.));
#300 = DIRECTION('',(0.,0.,1.));
#301 = DIRECTION('',(1.,0.,-0.));
#319 = STYLED_ITEM('color',(#320),#249);
#320 = PRESENTATION_STYLE_ASSIGNMENT((#321));
#321 = SURFACE_STYLE_USAGE(.BOTH.,#322);
#322 = SURFACE_SIDE_STYLE('',(#323));
#323 = SURFACE_STYLE_FILL_AREA(#324);
#324 = FILL_AREA_STYLE('',(#325));
#325 = FILL_AREA_STYLE_COLOUR('',#326);
#326 = COLOUR_RGB('',0.800000010877,0.500000003429,0.199999998682);

The complete file

— a set of styled items (or layer assignments, draughting callouts, or whole representations) that are not to be displayed. INVISIBILITY itself carries only a list of items; to hide something in one view rather than everywhere, the subtype CONTEXT_DEPENDENT_INVISIBILITY adds a context — a presentation representation or a presentation set, and in AP242 a draughting model too, and it is rare in mechanical exchange except inside saved views, which belong to Chapter 16.

14.6 Names on geometry

Not appearance, but often asked about in the same breath: where is the name of a face? Every representation item has a name attribute, and it is almost always ''. Some systems — NX and Creo among them, when asked — write the user’s face or body name there: ADVANCED_FACE('Mounting surface',(#18),#52,.F.). The only other place is from outside: a SHAPE_ASPECT whose name is the label and whose GEOMETRIC_ITEM_SPECIFIC_USAGE points at the face, the mechanism Chapter 16 uses for datum features; few exporters use it for plain names. Feature names go the same way or not at all: the B-rep knows nothing about holes, fillets or pockets, only about faces, and although AP242 defines feature records, mainstream exporters do not write them.

WarningIn the wild: What AP203 files cannot say

STYLED_ITEM, COLOUR_RGB and PRESENTATION_LAYER_ASSIGNMENT are not in AP203 first edition (CONFIG_CONTROL_DESIGN). A file with that schema is grey and layerless by definition. Files exist that declare CONFIG_CONTROL_DESIGN and contain colour records anyway; strict readers drop the colours and lenient ones keep them. AP203 second edition added presentation; AP242 carries everything here.

ImportantIn brief

Colour reaches geometry from the outside: a STYLED_ITEM points at a solid, face or curve and at a PRESENTATION_STYLE_ASSIGNMENT, which descends through five fixed records to a COLOUR_RGB or a named colour. Styled items are collected in a MECHANICAL_DESIGN_GEOMETRIC_PRESENTATION_REPRESENTATION or, in files with PMI, a DRAUGHTING_MODEL. A face colour overrides a body colour only through an OVER_RIDING_STYLED_ITEM. Layers are PRESENTATION_LAYER_ASSIGNMENTs listing their members. Face names live in representation_item.name, when they live anywhere.