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');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:
#326COLOUR_— 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.)RGB #325FILL_— a colour used for filling areas. The alternative is a hatch pattern or a tile.AREA_ STYLE_ COLOUR #324FILL_— a set of fill styles (here, one). Fill styles are what a face gets; curve styles are what an edge gets.AREA_ STYLE #323SURFACE_— the fill style applied as a surface style element. Other elements exist for boundaries, silhouettes, parameter lines, rendering.STYLE_ FILL_ AREA #322SURFACE_— a set of surface style elements for one side of a surface.SIDE_ STYLE #321SURFACE_— that side style applied toSTYLE_ USAGE .BOTH.sides of the surface (or.POSITIVE.or.NEGATIVE.).#320PRESENTATION_— a set of styles (here, one surface style usage) to be assigned together.STYLE_ ASSIGNMENT #319STYLED_— the assignment.ITEM nameis'color',stylesis(#320), anditemis#249: the pin’sMANIFOLD_. 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.SOLID_ BREP #318MECHANICAL_— a representation whose items are styled items, in the same geometric context as the geometry it decorates (DESIGN_ GEOMETRIC_ PRESENTATION_ REPRESENTATION #302). Its job is to be a container a reader can look for. There are two such containers in practice, this one andDRAUGHTING_, 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.MODEL
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_ 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_ with #88 an ADVANCED_ 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_ — a Part 46 subtype of STYLED_ 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_ instead of a surface style: CURVE_ — 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_, whose style_ 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_ is one of two colour entities. The other:
#340 = DRAUGHTING_PRE_DEFINED_COLOUR('red');A DRAUGHTING_ 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.));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_ 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);— 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_ 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_. The only other place is from outside: a SHAPE_ whose name is the label and whose GEOMETRIC_ 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.
STYLED_, COLOUR_ and PRESENTATION_ are not in AP203 first edition (CONFIG_). A file with that schema is grey and layerless by definition. Files exist that declare CONFIG_ and contain colour records anyway; strict readers drop the colours and lenient ones keep them. AP203 second edition added presentation; AP242 carries everything here.
Colour reaches geometry from the outside: a STYLED_ points at a solid, face or curve and at a PRESENTATION_, which descends through five fixed records to a COLOUR_ or a named colour. Styled items are collected in a MECHANICAL_ or, in files with PMI, a DRAUGHTING_. A face colour overrides a body colour only through an OVER_. Layers are PRESENTATION_s listing their members. Face names live in representation_, when they live anywhere.