TIA Portal V14 Snippet Management Reusing LAD/FBD Code

David Krause12 min read
SiemensTechnical ReferenceTIA Portal
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

TIA Portal V14 Snippet Management: Reusing LAD/FBD Code Efficiently

Engineers writing repetitive logic in TIA Portal V14 quickly discover a gap: there is no native "snippet library" for LAD or FBD networks. This reference documents the practical workarounds available in V14 (and the surrounding V13/V15 release window) for storing, previewing, and re-inserting blocks of graphical code, plus the scripting and external-editor paths that fill the gap until Siemens adds a first-class feature.

1. The Problem: Repeated Networks Without a Native Store

In ladder (LAD) and function block diagram (FBD) editors, a typical automation project contains dozens of identical or near-identical rungs:

  • Motor permissives: Start_PB AND Not_E_Stop AND Running seal-in branches with overload trip handling.
  • Analog scaling: AIW * Scale + Offset with raw/engineering conversion and clamping.
  • Pump alternation: lead/lag select with run-time hour tracking.
  • Alarm generation: Tag >= Limit AND Not_Ack with latched bits and timestamp capture.

Copying these from an existing block works, but cross-block or cross-project reuse has no UI. TIA Portal V14's Project Library view accepts:

  • Blocks (FB, FC, OB, DB, UDT) as Master Copies or Types.
  • Watch tables, tag tables, HMI screens.
  • Entire devices (CPU, HMI panel, drive).

What it does not accept: a single LAD network, an FBD segment, or an arbitrary SCL code region stripped from a block. Storing these requires one of the workarounds below.

Compatibility note. Behavior described here targets TIA Portal V14 SP1 (and the related V13 SP1 / V15 releases). V17+ introduced incremental library improvements but did not add a discrete "snippet" pane; the workarounds remain valid.

2. Master Copies vs. Types: Use the Library Properly First

Before resorting to external tooling, exhaust the official library features. The TIA Portal Project Library pane (right side of the Portal view) holds two categories of stored object:

Category Stored As Edit After Save Firmware Coupling Typical Use
Master copy Snapshot, looser coupling Yes, can be modified and re-saved as new version None Reusable code blocks copied into multiple projects
Type Fingerprint + version Controlled; instances update on sync One or more firmware versions Standardized blocks (e.g., a validated FB for a custom device)

If your repeated network belongs to a full FB or FC, lift the entire block into the library as a master copy:

  1. Right-click the block in the project tree → Copy.
  2. Open Libraries → Project library.
  3. Right-click Master copies → Paste.
  4. Optionally drag it into Types to enable fingerprint tracking and version upgrades.

The benefit: a master copy survives across projects and across TIA versions, and you can drag it into any block editor as a working starting point. The cost: it is the entire block, not a single network.

3. Reference Project Workaround (The Recommended Path)

For LAD/FBD networks that live inside a larger block, the cleanest in-TIA workaround is a reference project. A reference project is a read-only project attached to the active session that exposes its blocks for copy/paste into the editing project.

3.1 Build the Snippet Project

  1. Create a new S7-1500 (or matching target) project SnippetLibrary_V14.ap14.
  2. Under Program blocks, create a stub FB for every snippet category: FB_Scale_AI, FB_Motor_Permissive, FB_Pump_Alternation, FB_Alarm_Latch, FB_Valve_Control, etc.
  3. Inside each stub FB, place the canonical network(s). Use placeholder tag names with an obvious prefix such as _SNIP_ so search-and-replace is fast.
  4. Mark the project as not compilable (deliberately): leave tags declared in the snippet DB unassigned. The reference project is opened read-only and never compiled to hardware.

3.2 Attach the Reference Project

  1. In the active project, choose Options → Reference projects.
  2. Click Add and select SnippetLibrary_V14.ap14.
  3. Press Ctrl-9 to toggle the Reference projects task card on the right side of the editor.
  4. Expand the snippet FB, select the network, Ctrl-C, switch to the target project, and Ctrl-V into the destination FB.

3.3 Limitations and Workarounds

Limitation Mitigation
Reference project is read-only; cannot save back changes Maintain the snippet as the canonical source; copy forward only
Tags do not exist in the active project → paste shows broken references Use a consistent _SNIP_ prefix and a global search/replace after paste
Cannot compare two read-only snippet projects offline Open snippet project directly in a second TIA instance for side-by-side compare
Snippet project must use a CPU matching the target family Maintain one snippet project per CPU family (S7-1200, S7-1500, ET200SP)

The reference-project path is the answer that works today, requires no scripting, and integrates with the standard TIA diff/compare tools.

4. Keystroke Macros: Low-Tech but Reliable

For engineers who do not want to manage a snippet project file, a keystroke recorder treats network authoring as a macro. A common Windows-side approach:

  1. Use a recorder such as AutoHotkey or the built-in Macro Recorder (PowerToys) on Windows 10/11.
  2. Open the snippet FB in TIA Portal, position the cursor on the first empty network, and record the entire sequence: insert contact, type tag, add normally-open contact, drop output coil, etc.
  3. Stop recording and assign the macro to a hotkey such as Ctrl+Shift+M.
  4. In the destination project, press the hotkey; the recorder replays the keystrokes into the active LAD editor.

Advantages: works on every V14 install with no extra software, no project tree pollution. Disadvantages: brittle against dialog or layout changes, no syntax check, no preview, and you must reset cursor position manually between blocks.

5. SCL Snippet Management via VS Code

For SCL, the situation is dramatically better. VS Code (with the discontinued but still functional Siemens SCL Extension or community alternatives) treats SCL as plain text and inherits VS Code's snippet engine. A user snippet file scl.code-snippets in %USERPROFILE%\AppData\Roaming\Code\User\snippets\ looks like:

{
  "Motor Permissive Seal-In": {
    "prefix": "motorperm",
    "body": [
      "IF \"Start_PB\" AND NOT \"E_Stop\" AND NOT \"Fault\" THEN",
      "  \"Run_Cmd\" := TRUE;",
      "END_IF;",
      "IF \"Stop_PB\" OR \"Fault\" THEN",
      "  \"Run_Cmd\" := FALSE;",
    "END_IF;"
    ],
    "description": "Standard motor seal-in rung, edit tags after paste"
  },
  "Analog Scale": {
    "prefix": "aiscale",
    "body": [
      "// Raw 0..27648, Eng 0..100.0",
      "\"Eng\" := INT_TO_REAL(\"Raw\") / 27648.0 * 100.0;",
      "IF \"Eng\" > 100.0 THEN \"Eng\" := 100.0; END_IF;",
      "IF \"Eng\" < 0.0 THEN \"Eng\" := 0.0; END_IF;"
    ]
  }
}

Once the file is saved, typing motorperm followed by Tab expands the snippet with editable placeholders. After expansion, paste the body into the TIA Portal SCL editor. The disadvantage is that TIA Portal's SCL editor does not share state with VS Code, so tag autocomplete is unavailable. The advantage is the snippet engine itself, including tab stops, multi-cursor edits, and JSON-driven storage that fits in version control.

Tag-name caveat. Use symbolic SCL tag references ("Start_PB") rather than absolute addresses (%I0.0). Symbolic references survive paste into a different DB or instance, and the TIA compiler resolves them at build time.

6. TIA Openness: The Scripted Snippet Manager

For teams that need a real snippet manager for LAD/FBD, the only path is TIA Openness, the .NET API exposed by the TIA Portal installation. Openness allows a C# or PowerShell tool to import/export XML representations of blocks and to manipulate the project programmatically.

6.1 What Openness Can Do

  • Create or modify blocks (FB, FC, OB, DB) on the S7-1500/1200 targets.
  • Insert networks, contacts, coils, and SCL source code into existing blocks.
  • Read/write project library master copies and types.
  • Generate entire projects from templates (used heavily by machine OEMs).

6.2 What Openness Cannot Do (V14)

  • Insert a network into a block that is currently open in the editor (locks the project).
  • Round-trip a single network to a portable snippet file — networks are not first-class export objects.
  • Match the visual fidelity of drag-and-drop in the editor (positions, comments, bookmarks must be scripted).

6.3 Minimal Openness Snippet Example (C#)

The following pseudo-snippet shows the Openness call shape required to import SCL source into a block. A full snippet manager wraps this in a JSON catalog, a UI, and tag substitution.

// using Siemens.Engineering;
// using Siemens.Engineering.SW.Blocks;

public void ImportSclIntoFc(PlcBlockComposition composition, string source, string blockName)
{
    PlcBlockUserFunction fc = composition.Find(blockName) as PlcBlockUserFunction;
    if (fc == null) throw new InvalidOperationException($"Block {blockName} not found");

    BlockSclSource scl = fc.GetSclSource();
    string body = System.IO.File.ReadAllText(source);
    scl.CodeBody = body;
    fc.Comment = $"Generated by SnippetManager at {DateTime.UtcNow:O}";
}

For LAD/FBD insertion, the equivalent call is the ICFCInterface / network-graph objects; expect a 5x–10x code volume and a dependency on the private TIA assembly version that ships with the installation.

7. STEP 7 Classic Comparison

STEP 7 Classic (the V5.x predecessor) had a concept called Source files for STL/SCL and a separate FBD/LAD source generation path. Engineers sometimes recall it as "built-in snippet support," but the actual mechanism was STL/SCL source files: text representations of blocks that the compiler turned into executable code.

Feature STEP 7 Classic TIA Portal V14
STL source files Yes (text import/export) Removed; SCL replaces STL
SCL source files Yes Yes (blocks exportable as SCL source)
LAD/FBD source files No native text source No native text source
Library types with versioning Yes (S7 library) Yes (Project library, with fingerprints)
Snippet preview pane No No

The migration from Classic to TIA did not lose snippet capability because Classic never had it for LAD/FBD in the first place — only for STL/SCL text. If you are migrating a Classic workflow, the right translation is "SCL source files → VS Code snippet JSON" and "LAD/FBD repetition → reference project."

8. Cross-Platform Note: Studio 5000 / Logix Designer

Rockwell Studio 5000 has its own Add-On Instructions (AOI) which is a closer analog to a TIA Type than to a snippet. There is no native network-snippet pane in Studio 5000 either. If your team uses both ecosystems, the realistic cross-platform snippet story is:

  1. Author the canonical logic once in SCL (TIA) and again in Structured Text (Studio 5000).
  2. Maintain a JSON manifest that records the tag mapping between the two platforms.
  3. Use the snippet JSON for VS Code expansion in both editors.

Attribute transfer between Rockwell and Siemens is a long-standing request, but it is not a TIA Portal V14 feature and should not be expected from a future update either.

9. Building a Sustainable Snippet Workflow

The pragmatic TIA Portal V14 setup that survives a multi-year project is a hybrid of the techniques above:

  1. Full reusable blocks → project library Type with version tracking.
  2. LAD/FBD sub-network snippets → reference project SnippetLibrary_V14.ap14, attached on demand.
  3. SCL snippets → VS Code user snippets in version control, pasted into the TIA SCL editor.
  4. One-off macro sequences → keystroke recorder, no maintenance burden.
  5. OEM-scale generation → TIA Openness script that ingests a JSON snippet catalog and generates blocks.

Store the reference project and the VS Code snippet folder in the same repository. Add a README.md that documents tag-prefix conventions, target CPU family, and the paste procedure. When a snippet is updated, commit the change with a clear message; do not rely on memory.

10. Verification: Does the Snippet Paste Correctly?

After inserting any snippet into a destination block, run this checklist before saving the project:

  1. Compile the project. Any unresolved tag shows up as a compile error pointing at the pasted network.
  2. Cross-reference the placeholder tags. Replace every _SNIP_* tag with the project-specific instance or symbol.
  3. Monitor the tags online in a watch table; toggle the inputs and confirm the outputs follow the expected ladder logic.
  4. Compare against the canonical snippet using the TIA Compare tool with the snippet project as the reference. Any divergence flags a paste error.
  5. Force a download to the target PLC (in Stop mode) and observe the first scan for unexpected behavior on retentive tags.
Safety warning. Snippets that originate from a different safety integrity level (SIL) or from a non-validated source must never be pasted into a safety-related FB (F-runtime group). Maintain a separate safety snippet library and apply the standard V14 safety lifecycle (sign-off, version stamp) before reuse.

11. Troubleshooting Matrix

Symptom Likely Cause Fix
Reference project does not appear under Ctrl-9 Project file is locked, corrupted, or wrong TIA version Verify the .ap14 opens in a fresh TIA instance; re-save with V14 SP1 if needed
Compile error "Tag _SNIP_X not declared" Placeholder tags not yet renamed Use Find/Replace in the block; confirm consistent prefix
Pasted network has all contacts grayed out Source snippet used a different data type (BOOL vs. INT) Recompile the snippet with the destination's data type; re-paste
VS Code snippet expands in TIA SCL editor with wrong indentation TIA SCL auto-indent on paste Disable TIA auto-format temporarily: Options → PLC programming → SCL
TIA Openness throws HmiEngineeringNotLoaded Openness API not registered at install Re-run the TIA installer, select Openness under Additional software
Library type does not update after editing the master Fingerprint did not change Bump the version comment or the interface signature, then re-save the type
Keystroke macro inserts into wrong network Cursor was not reset before playback Click into the first empty network, then trigger the hotkey

12. Future Direction

Siemens has not published a roadmap item for a native LAD/FBD snippet pane. Community interest is high and TIA Openness makes a third-party snippet manager feasible for a C#-capable integrator. The realistic short-term bet is a small internal tool that wraps Openness: a snippet JSON catalog, a tag-substitution engine, and a UI that talks to the running TIA Portal. Until that exists, the reference-project-plus-VS-Code combination described above is the most maintainable workflow for TIA Portal V14.

Can I store a single LAD network as a master copy in TIA Portal V14?

No. Master copies and library types apply to whole blocks (FB, FC, OB, DB) and devices, not to individual networks. Use a reference project to hold snippet FBs and copy networks from there into the active project.

What is the fastest way to reuse an FBD scaling block across many projects?

Lift the full FB into the project library as a Type with a versioned fingerprint, then drag it into each project. The type-version upgrade workflow keeps instances synchronized when the canonical block changes.

Does VS Code support SCL snippets directly in the TIA Portal SCL editor?

No. TIA's SCL editor does not load VS Code snippets. The pragmatic pattern is to expand the snippet in VS Code, copy the body, and paste it into the TIA SCL editor with auto-indent disabled in Options → PLC programming → SCL.

Can TIA Openness paste a network from a snippet file into an open block?

Not while the block is open in the editor. Openness operates on the project tree; you must close the block, run the script, then reopen. Round-tripping a single network as a portable file is not supported in V14.

How do I compare two snippet projects offline in TIA Portal V14?

Open one snippet project directly in a second TIA instance and use Options → Compare against the other as the reference. The reference-project task card does not support a side-by-side offline-offline compare of two read-only projects.

Back to blog