COMOS Standard Table Color Codes: RGB Integer Conversion

David Krause19 min read
Other TopicSiemensTechnical Reference
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

Overview: COMOS Standard Table Color Definition

COMOS standard tables drive presentation attributes across reports, P&IDs, and pipe line graphics in Siemens COMOS. The standard table address format @40|Y00|A10|B50|Y00N00338 references a single cell in a multi-tab table that supplies values such as line width, line type, and color. When the source specification provides color in RGB (Red, Green, Blue) triplets, the engineer must translate that triplet into the integer that COMOS expects in the color column. This reference documents the address notation, the integer encoding rule, the conversion workflow using the Object Debugger, and the four common storage patterns (direct integer, separate XValues, delimited string, preview symbol) used in production COMOS databases. It also covers the SubOnChange script wiring on the media attribute, the symbol-column preview technique, the standard pipe color codes per DIN 2403 / ISO 14726, a verification procedure, and a troubleshooting matrix derived from field commissioning experience.

COMOS Standard Table Address Notation

The address @40|Y00|A10|B50|Y00N00338 follows the COMOS cell-reference grammar. Each segment identifies a different scope level. Decoding the segments:

Segment Meaning Example Value
@40 Row index in the target tab. The row may be 0-based or 1-based depending on the tab configuration; verify with the Object Debugger for the specific standard table being used. 40
Y00 Target tab identifier. Y-prefixed tabs are the standard engineering tabs supplied with the COMOS base data set. Y00
A10 Column letter A, sub-row 10. The letter is the column, the integer is the sub-row within a hierarchical column. A10
B50 Column letter B, sub-row 50. B50
Y00N00338 Attribute name on tab Y00 with the named identifier N00338. This is the destination attribute that consumes the value returned by the cell reference. Y00N00338

For color definition, one of the sub-rows (commonly B50) carries the integer color value that the COMOS graphic engine renders as the line stroke color. The remaining sub-rows carry width, dash pattern, layer information, and any other presentation attributes the customer requires. Always confirm the destination cell with the customer's COMOS administrator before bulk entry; the cell holding the color varies between base data releases and customer-modified base data sets.

RGB Color Model and COMOS Integer Encoding

The RGB color model is an additive model in which red, green, and blue light channels are combined to reproduce a broad spectrum of colors. Each channel is typically an 8-bit integer in the range 0-255, producing 2563 = 16,777,216 distinct values. A pure red is (R=255, G=0, B=0), pure green is (0, 255, 0), pure blue is (0, 0, 255), and white is (255, 255, 255). COMOS receives these triplets from the spec and must store them in the single integer field of the standard table cell.

COMOS encodes a color as a single 24-bit integer. The byte order used by COMOS for the standard table color cell is the Windows COLORREF / BGR layout, where the low byte carries red, the next byte green, and the high byte blue:

Color_int = R + (G * 256) + (B * 65536)

Worked examples for common pipe colors (assuming pure channel values):

Color R G B Formula Application Color_int (Decimal)
Black 0 0 0 0 + 0 + 0 0
White 255 255 255 255 + 65280 + 16711680 16777215
Red (warm water feed) 255 0 0 255 + 0 + 0 255
Green 0 255 0 0 + 65280 + 0 65280
Blue (warm water return) 0 0 255 0 + 0 + 16711680 16711680
Yellow 255 255 0 255 + 65280 + 0 65535
Cyan 0 255 255 0 + 65280 + 16711680 16776960
Magenta 255 0 255 255 + 0 + 16711680 16711935
Gray (50%) 128 128 128 128 + 32768 + 8388608 8421504
Verify the byte order against the target COMOS release. The BGR convention above is the dominant layout in COMOS standard tables, but earlier or customer-modified base data may use RGB order (R*65536 + G*256 + B). Confirm by entering a known RGB (e.g., 255, 0, 0) in a test cell and reading back the rendered color in the COMOS graphic preview. If the preview shows blue, the byte order is reversed and the alternative formula applies. Always perform this verification on a non-production copy of the base data before bulk import.

Prerequisites

  • COMOS 10.x or COMOS Walkinside with administrative rights on the base project (read/write on standard tables and the affected tabs).
  • Object Debugger access (Tools > Object Debugger) for direct value extraction and quick evaluation of color expressions.
  • Knowledge of the target tab (typically Y00) and the column holding the color integer (commonly B50 in the pipe-line standard table; verify against the customer's base data set).
  • Customer-supplied color list in RGB triplets (R, G, B), 0-255 per channel. The list may be delivered as CSV, Excel, or a printed specification; all three forms are accepted workflows.
  • Optional: a script editor (COMOS script editor or an external editor such as Notepad++) for the SubOnChange wiring script on the media attribute.
  • Optional: a color picker utility for quantitative verification of the rendered pipe line color against the customer specification.
  • A non-production copy of the base data for byte-order verification and bulk-import dry runs.

Conversion Methods: From RGB Triplet to COMOS Integer

Four practical methods are used in production COMOS deployments. Choose based on the volatility of the customer color list, the bulk-import tooling available, and the audit trail required for the project quality record.

Method 1: Direct Extraction via Object Debugger

The Object Debugger can produce a usable integer if the source object already exposes a color attribute at the desired RGB value.

  1. Open Object Debugger on any object that has a color set to the desired RGB value (for example, a pre-formatted pipe segment from the customer's previous project).
  2. Evaluate the color expression. The COMOS Color function returns the integer directly. A common evaluator expression is Color(255, 0, 0) for pure red; the function returns 255 as the integer that the standard table accepts.
  3. Copy the returned integer and paste it into the standard table cell. The cell type is integer; do not enter the triplet string in the same field.
A naive entry such as RGB(255, 0, 0) may evaluate to 0 (always black) in some Object Debugger versions if the function expects the channels in BGR order rather than RGB order. Confirm by reading the rendered color from a known test object; if the rendered color is not red, swap the channel order in the function call or use the COMOS Color function with the documented signature for your COMOS release.

Method 2: Manual Calculation (Spreadsheet)

For batch conversion of a customer color list (often delivered as a CSV or Excel sheet with columns R, G, B), apply the formula directly in a spreadsheet before pasting into COMOS.

=A2 + (B2 * 256) + (C2 * 65536)

Where A2, B2, and C2 are the cells holding R, G, and B respectively. Round the result to the nearest integer (the formula is integer-only, but the spreadsheet may display a floating-point value; format the column as integer with no decimal places). The output column is then imported into the COMOS standard table cell using the COMOS CSV import on the tab, or via a script loop for very large lists.

Method 3: Separate XValues Storage

When the customer's source data is volatile or the color may need to be updated without re-importing the full table, store each channel as its own XValue on the standard table row.

  1. Add three XValue columns to the row: R_val, G_val, B_val, each an integer in the range 0-255.
  2. On read time, compute the integer via a calculation attribute or a script call: Color_int = R_val + (G_val * 256) + (B_val * 65536).
  3. Bind the result to the color attribute (for example, Y00N00338) using a calculation attribute or a script call.

This pattern allows the customer to update any single channel without recomputing the integer, reduces the risk of byte-order errors at import time, and produces an auditable trail of the source RGB triplet in the standard table itself.

Method 4: Delimited String Storage

For a compact storage representation, the three channels can be stored as a single delimited string, e.g., 255;0;0 (semicolon delimiter). On read time, split the string on the delimiter and apply the formula.

channels = Split(color_str, ";")
If UBound(channels) = 2 Then
    Color_int = CInt(channels(0)) + (CInt(channels(1)) * 256) + (CInt(channels(2)) * 65536)
End If

This pattern is the most space-efficient in the database but requires the script to handle malformed strings gracefully. Validate the length and channel count before evaluation; reject values outside 0-255 and reject strings that do not split into exactly three elements. Log the rejection to the project quality record if the customer may want to see which rows were skipped.

Wiring the Standard Table to a COMOS Media Attribute

For pipe line color driven by media, the standard table is bound to the media attribute, and a SubOnChange script propagates the color, line width, and line type to the runtime attributes on tab Y00T00039 when the user selects a media. The wiring sequence is:

  1. Add a standard table reference on the media attribute (commonly the Media tab in the attribute dialog of the pipe object).
  2. Populate one row per media. Columns: media code, line width, line type, color integer (in the convention chosen for the project).
  3. Write a SubOnChange script on the media attribute. The script reads the standard table row that matches the selected media code and writes the three values (width, type, color) to the destination attributes on tab Y00T00039.
  4. Trigger the script when the user changes the media code on any pipe object; COMOS propagates the new color to the pipe's runtime attributes automatically.

SubOnChange script skeleton (COMOS VBScript, structure only; adapt to your base project's attribute names and standard table layout):

Sub MediaAttr_OnChange()
    Dim stdTab, mediaCode, row
    mediaCode = Me.Media
    Set stdTab = GetStandardTable("@40|Y00|A10|B50")
    row = stdTab.FindRow("MediaCode", mediaCode)
    If row >= 0 Then
        Me.LineWidth = stdTab.GetValue(row, "LineWidth")
        Me.LineType  = stdTab.GetValue(row, "LineType")
        Me.LineColor = stdTab.GetValue(row, "ColorInt")
    End If
End Sub

The user selects the media once on the pipe; the rest of the line styling is automated. This pattern keeps the customer color list in a single editable location (the standard table) and prevents per-pipe color drift caused by manual line color assignment. The script also reduces the time required to apply a customer color change across an entire project: updating the standard table propagates to all pipes on the next OnChange event or next standard table redraw.

Color Preview and Self-Documenting Standard Tables

To make the standard table self-documenting, add a symbol column that previews the color. The symbol is bound to the color integer via a graphic reference; the COMOS graphic engine renders the symbol with the fill color set to the cell value. The engineer opening the standard table sees a swatch in the row, which makes it easy to spot wrong integers without launching a P&ID. Implementation outline:

  1. Add a Symbol column to the standard table (right-click the column header in the standard table editor and choose Insert Symbol Column).
  2. Bind the symbol's fill color to the ColorInt column via attribute reference. The symbol's fill attribute reads from the same standard table cell that drives the pipe line color.
  3. When the ColorInt value changes, the swatch updates on the next standard table redraw. No manual refresh is required if the standard table is set to auto-refresh on cell change.

Best practice: add the symbol column as the first column after the media code so the swatch is immediately visible. Color the symbol border in a neutral gray to avoid introducing additional color noise in the table.

Standard Pipe Color Reference (DIN 2403 / ISO 14726)

Customer pipe specifications commonly follow DIN 2403 (identification of pipes according to the fluid conveyed) or ISO 14726 (ships and marine technology). Pre-computed COMOS color integers for the most common media are provided below for quick reference; always use the customer's exact RGB triplet in production, since the values from the specification govern the rendered color.

Media DIN 2403 Color R G B Color_int
Warm water feed Red 255 0 0 255
Warm water return Blue 0 0 255 16711680
Cold water Green 0 128 0 32768
Steam Red-brown 139 69 19 4587795
Compressed air Light blue 0 191 255 16744448
Fuel oil Brown 165 42 42 2768682
Acids Orange 255 165 0 42495
Alkalis Violet 238 130 238 15624734
Fire-fighting water Red 255 0 0 255
Process water Green 0 128 0 32768
Natural gas Yellow 255 255 0 65535
Oxygen (medical) White 255 255 255 16777215
Vacuum Gray 128 128 128 8421504
Drain Black 0 0 0 0
The RGB values above are reference values matching the visual hue of the DIN/ISO swatch. Customer specifications may deviate from the reference swatch; always use the customer's exact RGB triplet, not the values from this table. Also note that some customers specify pipe identification with a base color plus a contrasting stripe color; in that case, the line color attribute carries the base color and the stripe color is set on a separate attribute, typically on the same standard table row.

Verification Procedure

  1. Open a test P&ID that contains at least one pipe per media code in the customer color list. If a dedicated test P&ID is not available, create one and place one pipe object per media code.
  2. Trigger a redraw (View > Refresh or F5). The COMOS graphic engine re-reads the standard table on the next render cycle.
  3. Inspect each pipe line. Compare the rendered color to the customer's RGB triplet using a color picker on a screenshot, or visually if the hues are well separated. For grayscale cases (e.g., drain black, vacuum gray), verify against a grayscale reference.
  4. For a quantitative check, use a third-party color picker on the rendered graphic and confirm that the read-back R, G, B channels match the customer's specification within +/- 2 per channel. Anything outside this tolerance indicates a byte-order error or a mis-formatted integer.
  5. Verify the standard table symbol column renders the same swatch. A mismatch between the symbol swatch and the pipe line color indicates that the binding of the color integer to the pipe attribute is broken or that the pipe is reading from a different standard table cell than the symbol.
  6. Document the verified color list in the project quality record; include the COMOS color integers, the customer's RGB triplets, and the screenshot evidence. Archive the verification artifacts with the as-built project documentation.
  7. Repeat the verification after any change to the base data (COMOS update, base data migration, customer base data update). The byte order has been observed to change between major COMOS releases in some customer environments.

Troubleshooting Matrix

Symptom Likely Cause Fix
Pipe renders black after integer entry. Byte order reversed; the formula used RGB order (R*65536 + G*256 + B) instead of BGR order, or vice versa. Swap to R + G*256 + B*65536 (BGR) or to R*65536 + G*256 + B (RGB); re-enter the integer. Verify on a non-production copy first.
Object Debugger returns 0 for RGB(255, 0, 0). The Object Debugger version expects BGR channel order; the function call did not match the expected order for the COMOS release. Use the COMOS Color function with the documented signature for your release, or compute the integer manually with the formula. Verify the rendered color from a known test object before trusting the integer.
Pipe color updates on some pipes but not others. SubOnChange script on the media attribute is not firing; the pipe's media attribute was set before the script was installed or before the binding was repaired. Re-set the media attribute on the affected pipes; the OnChange event fires on a value change, not on script installation. For very large numbers of affected pipes, run a project-wide script that re-assigns the media value to itself to trigger the OnChange event.
Standard table symbol shows correct swatch but pipe line is wrong color. Standard table and pipe attribute binding are different; the runtime attribute is not reading from the same standard table row as the symbol column. Verify the binding; the line color attribute on the pipe must point to the same standard table cell as the symbol column. Re-bind the pipe attribute to the correct cell.
Color integer is correct but hue is shifted (e.g., red renders as orange). Customer RGB triplet was entered with the wrong channel order; the customer uses BGR triplets, not RGB. Confirm with the customer whether the triplet is R,G,B or B,G,R; recompute the integer with the correct order if necessary.
Customer color list is large (100+ rows); manual entry is impractical. Manual entry is error-prone at this scale and produces a poor audit trail. Use the spreadsheet formula =A2 + (B2 * 256) + (C2 * 65536) on the full list, then import the integer column via the COMOS CSV import on the standard table. Keep the import file under the COMOS CSV import size limit (typically 10,000 rows; check your release's documentation).
Color integer changes do not propagate to existing P&IDs. Runtime attributes on tab Y00T00039 were cached at object creation time; the standard table is read at runtime, but the cache has not expired. Force a redraw and re-evaluate the runtime attributes; in extreme cases, re-set the media on each pipe to force the OnChange event. For project-wide changes, run a script that triggers a re-evaluation of the line color attribute on all pipe objects.
Symbol column shows a different color than the integer column value. The symbol's fill binding is reading from a different attribute than the line color binding; the two attributes may be reading from different standard table rows. Verify both bindings reference the same standard table row and column. If the symbol is on a separate row, rebind it to the row that drives the pipe line color.
Printed P&ID shows different colors than the on-screen rendering. The print color profile differs from the screen color profile; COMOS uses the printer color profile when generating the print output. Configure the print color profile in the COMOS print settings to match the on-screen profile, or print to PDF and verify the colors in the PDF viewer. Note the discrepancy in the project quality record if the customer accepts a known print color shift.
Color integer is rejected by the standard table cell validation. The integer is outside the valid 24-bit range (0 to 16,777,215) or the cell type is not configured as integer. Check the channel values are in 0-255 and the formula result is in 0-16777215. If the cell type is text, change the cell type to integer in the standard table schema.

Field-Proven Best Practices

  • Always perform a byte-order verification on a non-production copy of the base data before bulk import. The cost of the verification is small compared to the cost of a project-wide color correction.
  • Use the symbol column from the start. Engineers reviewing the standard table years after the initial configuration will rely on the swatch to interpret the integer values; a column of bare integers is not self-documenting.
  • Keep the customer color list in the standard table, not in a separate project document. The standard table is the single source of truth for the project; any external document is a candidate for drift.
  • For very large color lists (1000+ rows), generate the integer column in a spreadsheet and import via CSV rather than entering integers in the COMOS standard table editor one at a time. The COMOS editor is not optimized for bulk numeric entry.
  • Document the byte order convention in the project quality record. Future engineers working on the project will need to know whether the integers are BGR or RGB, since the formula depends on the convention.
  • When the customer issues a color change, update the standard table first and let the OnChange event propagate. Do not edit the line color attribute on individual pipe objects; manual edits will be overwritten by the next OnChange event and will create drift between the standard table and the runtime attributes.
  • Back up the base data before any bulk import. A failed import may leave the standard table in an inconsistent state, and the only recovery is a base data restore.

FAQ

What does the @40|Y00|A10|B50|Y00N00338 address mean in a COMOS standard table?

The format decomposes into row 40 of tab Y00, column A sub-row 10, column B sub-row 50, and the destination attribute Y00N00338. The sub-row holding the color integer is typically B50; verify against the customer's base data and the COMOS administration guide for the exact cell holding the line color value, since the cell location varies between base data releases.

What formula converts an RGB triplet to a COMOS color integer?

Use Color_int = R + (G * 256) + (B * 65536) in the BGR convention. Worked examples: pure red (255, 0, 0) = 255; pure blue (0, 0, 255) = 16711680; pure green (0, 255, 0) = 65280; white (255, 255, 255) = 16777215. Confirm the byte order against a known test object before bulk import; if the test renders the wrong hue, swap to the RGB variant of the formula.

How do I avoid re-typing the integer for every media in the standard table?

Compute the integer in a spreadsheet column with =A2 + (B2 * 256) + (C2 * 65536), then import the integer column via the COMOS CSV import on the standard table. The import replaces the integer cell values without disturbing the other columns (media code, line width, line type) when the import key is the media code.

Can I store the three RGB channels separately in the standard table?

Yes. Add three XValue columns (R_val, G_val, B_val) and compute the integer on read time with a calculation attribute or a script. This pattern is preferable when the customer's color list is volatile, because only the affected channel needs to be updated and the byte order is applied at the read step, not at the import step. The standard table then shows the source RGB triplet directly, which simplifies audit and verification.

Why does the Object Debugger return 0 for an RGB function call?

The Object Debugger in some COMOS releases expects the channels in BGR order; a call formatted as RGB(255, 0, 0) may evaluate to 0 if the function signature is actually BGR. Use the COMOS Color function with the channels in the order expected by your release, or compute the integer manually with the formula R + G*256 + B*65536 to avoid the dependency on the function signature.

Why does the printed P&ID show different colors than the on-screen rendering?

COMOS uses the printer color profile when generating print output, which may differ from the screen color profile. Configure the print color profile in the COMOS print settings to match the on-screen profile, or print to PDF and verify the colors in the PDF viewer. Document any accepted color shift in the project quality record.

Back to blog