Niagara PRO TIPS: PX Includes - Part 1
Video Tutorial: Niagara PRO TIPS: PX Includes - Part 1
NOTE:
If you want to watch the video while following along with the text notes, then right click and open the video in a new split screen window and the video should appear on the right of the notes so that you can follow along.
Overview
This guide covers the basics of PX includes in Niagara 4, including how to create reusable PX components and how to use variables in PX includes for powerful, efficient graphics development. Part 1 focuses on fundamentals and variable substitution techniques.
What are PX Includes?
PX Includes are reusable PX files that can be embedded into other PX files as single widgets. They allow you to:
-
Create common UI components once and reuse them across multiple graphics
-
Maintain consistency across all PX views
-
Reduce engineering time and effort
-
Minimize errors from repetitive manual configuration
-
Update content in one place and have it apply everywhere
Basic PX Include Concepts
File Organization
Best Practice: Create an includes folder in your PX directory to organize PX include files.
Station Structure:
โโโ px/
โโโ includes/
โ โโโ header.px
โ โโโ zone_detail.px
โ โโโ table_header.px
โ โโโ odd_row.px
โโโ equipment_schedule.px
โโโ floor_plan.px
Designing PX Include Files
When creating a PX file intended for use as an include, consider these design principles:
1. Use Canvas Pane as Root Element
Important: The root element should be a canvas pane, not a scroll pane.
Why?
-
PX includes are embedded as widgets in other files
-
Canvas panes provide fixed sizing and positioning
-
Scroll panes add unnecessary complexity when embedded
2. Configure Scaling Settings
Recommended Setting: Set scaling to None
How to Configure:
-
Select the canvas pane
-
Look at canvas pane settings
-
Set scaling to
None
Why?
-
The parent PX file will handle scaling
-
Prevents double-scaling issues
-
Maintains predictable sizing
3. Size Appropriately
Set your canvas pane size to exactly what's needed for the content:
-
Not too large (wasted space)
-
Not too small (content won't fit)
-
Just right for the widgets you're including
Method 1: Simple PX Includes (No Variables)
Use Case: Common Headers and Navigation
Common elements you might include on all PX views:
-
Weather information
-
Hyperlinks to alarm console
-
Hyperlinks to history views
-
Web chart views
-
Company logos
-
Theme and general design elements
Creating a Simple PX Include
Step 1: Create the Include File
-
Navigate to
px/includes/folder -
Create new PX file (e.g.,
header.px) -
Design your content with labels, widgets, etc.
Step 2: Configure the Canvas
-
Ensure root element is a canvas pane
-
Set scaling to
None -
Size canvas to fit content
Step 3: Add Your Content
Add whatever widgets you want:
-
Labels with static text
-
Hyperlinks
-
Images/logos
-
Weather widgets
-
Navigation elements
Using a Simple PX Include
Step 1: Open Target PX File
Open the PX file where you want to embed the include (e.g., equipment_schedule.px)
Typical Structure:
Scroll Pane
โโโ Canvas Pane
โโโ (Your content here)
Step 2: Drag and Drop
-
From the station tree, locate your include file (e.g.,
px/includes/header.px) -
Drag and drop it onto your target PX file
-
This creates a PX Include Widget
Step 3: Position the Widget
-
The entire include appears as one item in the target PX file
-
Everything moves together as a unit
-
Easy to position consistently
Benefits of Simple PX Includes
โ
Consistency - All individual labels/widgets from source appear as one unit
โ
Easy Positioning - Move entire include as single item
โ
No Wiggling - Components stay together, don't shift around
โ
Single Source - Edit include file, changes appear on all pages using it
โ
Time Savings - Reduces engineering time significantly
โ
Consistent Graphics - Same look and feel across entire site
Method 2: PX Includes with Variables
Understanding the Challenge
Consider a floor plan graphic with multiple zones. Each zone label might have:
-
Bound Label Binding - Absolute ORD to equipment (e.g., air handler)
-
Hyperlink Property - Relative ORD to equipment graphic
-
Spectrum Binding - ORD to point for background color animation
-
Spectrum Set Point Binding - ORD for set point animation
Problem:
-
Zone 1 Label: 4 bindings = 4 ORDs to configure
-
Zone 1 Equipment Label: 2 bindings = 2 ORDs to configure
-
Total: 6 ORDs per zone
-
10 Zones: 60 ORDs to manually configure!
Solution: PX Includes with Variables
Example: Floor Plan Zone Details
The Problem Scenario
Two Labels per Zone:
Equipment Label (e.g., "AHU-01"):
-
Bound Label Binding: Absolute slot path to air handler
-
Hyperlink: Relative hyperlink to graphic detail
Room Temp Label:
-
Label Binding: ORD to room temperature point
-
Hyperlink: ORD to area
-
Spectrum Binding: ORD to room temp (animates background color)
-
Spectrum Set Point Binding: ORD (animates set point of spectrum)
Total ORDs to Configure:
-
Equipment Label: 2 ORDs
-
Room Temp Label: 4 ORDs
-
Total per Zone: 6 ORDs
Creating a PX Include with Variables
Step 1: Create New PX File
-
Navigate to
px/includes/folder -
Create new PX file (e.g.,
zone_detail.px)
Step 2: Configure Canvas Pane
-
Replace scroll pane with canvas pane:
-
Cut canvas pane
-
Delete scroll pane
-
Paste canvas pane back as root
-
-
Set scaling to None
-
Set canvas size to fit content:
-
Example: Width = 90, Height = 60
-
Just large enough to hold your widgets
-
Step 3: Copy Widgets from Original
-
Open your floor plan graphic
-
Select and copy the zone labels you want to template
-
Return to your
zone_detail.pxinclude file -
Paste the widgets
Result: Widgets with existing ORDs (mixture of relative and absolute)
Converting ORDs to Variables
Understanding Variable Syntax
Variable Format:
$(VariableName)/remaining/path
Components:
-
$- Dollar sign (indicates variable) -
(VariableName)- Variable name in parentheses (arbitrary name you choose) -
/remaining/path- Additional ORD path beyond the base component (if needed)
Conversion Rules
Rule 1: Base Component Replacement
Original ORD:
station:|slot:/Drivers/BacnetNetwork/AH_01
Variable ORD:
$(zone)
Explanation: The entire absolute slot path to the base component is replaced with the variable.
Rule 2: Base Component + Additional Path
Original ORD:
station:|slot:/Drivers/BacnetNetwork/AH_01/points/RoomTemp
Variable ORD:
$(zone)/points/RoomTemp
Explanation: Base component replaced by variable, additional path remains.
Rule 3: Relative ORD Conversion
Original Relative ORD:
slot:AH_01/graphic/detail
Variable ORD:
$(device)/graphic/detail
Explanation: The slot reference that resolves to the parameter device is replaced with the variable.
Important: Forward Slash Handling
โ ๏ธ Critical Detail:
When appending additional path to a variable, keep the leading forward slash:
Correct:
$(room_temp)/points/RoomTemp
โ
Keep the slash!
Why?
Because you're appending to the substituted ORD, the leading slash is necessary.
Contrast with Relative ORDs:
slot:points/RoomTemp
โ
No leading slash (relative syntax)
Step-by-Step Variable Conversion Example
Equipment Label Bindings
Binding 1: Bound Label Binding
Original:
station:|slot:/Drivers/BacnetNetwork/AH_01
Variable Conversion:
$(zone)
Binding 2: Hyperlink Property
Original:
slot:AH_01/graphic/detail
Variable Conversion:
$(equip)/graphic/detail
Room Temp Label Bindings
Binding 1: Label Binding
Original:
station:|slot:/Drivers/BacnetNetwork/AH_01/points/RoomTemp
Variable Conversion:
$(room_temp)/points/RoomTemp
Binding 2: Hyperlink
Original:
slot:AH_01/area
Variable Conversion:
$(peanut_butter)/area
(Yes, you can use arbitrary names like "peanut_butter"!)
Binding 3: Spectrum Binding
Original:
station:|slot:/Drivers/BacnetNetwork/AH_01/points/RoomTemp
Variable Conversion:
$(jelly)/points/RoomTemp
(Variable names are completely arbitrary)
Binding 4: Spectrum Set Point Binding
Original:
station:|slot:/Drivers/BacnetNetwork/AH_01/points/RoomTempSP
Variable Conversion:
$(zone)/points/RoomTempSP
Variable Naming Best Practices
Arbitrary But Meaningful
You Can Use:
-
$(zone) -
$(device) -
$(equipment) -
$(room_temp) -
$(peanut_butter)โ Valid but not recommended! -
$(jelly)โ Valid but not recommended!
Recommended Practice
Use the same variable name for all bindings that share the same base component:
All bindings using same base equipment:
- $(zone)
- $(zone)
- $(zone)
- $(zone)
Result: Only ONE variable to bind when using the include!
In the tutorial example, different variable names are used to emphasize the concept, but in practice, use consistent naming.
Using PX Includes with Variables
Step 1: Select Base Components
Instead of dragging the PX include file directly:
-
Navigate to the component tree
-
Select the base component(s) you want to bind to
-
Example: Select multiple air handlers
-
Can select single or multiple components
-
Step 2: Drag and Drop onto PX Editor
-
Drag the selected component(s) onto your PX editor
-
The Make Widget Wizard appears
Step 3: Choose "Include PX File"
-
In the Make Widget Wizard, select "Include px file"
-
Browse to your include file (e.g.,
zone_detail.px) -
Click to select it
Step 4: Bind Variables (The Magic!)
PX File Variables Section:
-
The wizard displays "Select px file variables define"
-
Shows all variables defined in your source PX file
-
Each variable from your include appears in the list
Example Variables Shown:
- $(zone)
- $(equip)
- $(room_temp)
- $(peanut_butter)
- $(jelly)
If You Used Consistent Naming:
- $(zone) โ Only one variable!
Step 5: Select Variables to Bind
Option A: Bind All (Typical)
-
Multi-select all variables
-
All will map to the same base component you dragged
Option B: Selective Binding
-
Choose only specific variables
-
Useful for advanced scenarios
Step 6: Click OK
Result:
-
PX include widgets are created
-
All widgets move together as one unit
-
Variables automatically bound to your selected component(s)
Viewing Variable Bindings
After creating PX includes with variables:
-
Select a PX include widget
-
Look at Properties
-
Find the Variables property
What You'll See:
Variables Property Explanation:
-
Left Side: Variable names from source file
-
Right Side: What they resolved to (absolute ORDs)
Example:
Variable Mapping:
$(zone) โ station:|slot:/Drivers/BacnetNetwork/AH_01
$(zone)/points/RoomTemp โ station:|slot:/Drivers/BacnetNetwork/AH_01/points/RoomTemp
$(zone)/points/RoomTempSP โ station:|slot:/Drivers/BacnetNetwork/AH_01/points/RoomTempSP
When No Additional Path:
-
Just the base component
-
Variable = Base ORD
When Additional Path Specified:
-
Base component + remaining path
-
Variable gets substituted, remainder appended
Benefits of PX Includes with Variables
Time Savings
Without Variables:
-
Zone 1: Manually configure 6 ORDs
-
Zone 2: Manually configure 6 ORDs
-
Zone 10: Manually configure 6 ORDs
-
Total: 60 ORDs to configure manually
With Variables:
-
Drag 10 components at once
-
Select PX include file
-
Bind variables (one click)
-
Done!
Error Reduction
โ
Eliminates "fat finger" errors - No manual ORD typing
โ
Consistency - All zones use same template
โ
No typos - Automatic substitution
โ
No missing bindings - Template includes everything
Efficiency
โ
Faster deployment - Drag and drop vs. manual configuration
โ
Rapid changes - Update include file, affects all instances
โ
Scalability - Works for 10 zones or 100 zones
Use Case 2: Equipment Schedule Tables
The Challenge
Building equipment schedule tables with traditional approaches:
-
Component Grids: Good, but limited design flexibility
-
VE Grids: Good, but limited design flexibility
-
Manual Labels: Maximum flexibility, but tedious to configure
Solution: PX Includes with variables for table rows!
Equipment Schedule Design
Component Structure
Table Header (Include #1):
-
File:
table_header.px -
Canvas pane sized to fit column headers
-
Contains labels with static text
-
Column headers for: Equipment Name, Status, Temperature, Setpoint, etc.
Odd Row (Include #2):
-
File:
odd_row.px -
Canvas pane sized to fit one row
-
Contains bound labels with variable ORDs
-
All labels use
$(zone)variable -
Light background color
Even Row (Include #3):
-
File:
even_row.px -
Identical to odd row (labels, bindings, size)
-
Only difference: Slightly different background color
-
Provides alternating row appearance
Creating Equipment Schedule Table
Step 1: Add Table Header
-
Open equipment schedule PX file
-
Drag
table_header.pxinclude -
Drop at top of page
-
Position as column headers
Result: Static header row with column titles
Step 2: Add Equipment Rows
-
From component tree, select all air handlers
-
Drag onto PX editor
-
Make Widget Wizard โ Include px file
-
Select
odd_row.px -
Bind variable:
$(zone)โ Selected air handlers -
Click OK
Result: Multiple PX include widgets, one per air handler
Step 3: Alternate Row Colors (Optional)
For better visual appearance:
-
Select even-numbered PX includes (2nd, 4th, 6th, etc.)
-
Look at properties
-
Find Include property (points to actual PX file)
-
Change from
odd_row.pxtoeven_row.px
Result: Alternating row colors in your table!
Equipment Schedule Configuration
Each Row's Bound Labels
All labels in odd_row.px use variable ORDs:
$(zone) โ Base air handler
$(zone)/points/Status โ Equipment status
$(zone)/points/RoomTemp โ Current temperature
$(zone)/points/RoomTempSP โ Temperature setpoint
$(zone)/points/FanStatus โ Fan status
... etc.
Key Point: One variable ($(zone)) used throughout = one binding operation!
Benefits for Equipment Schedules
โ
Design Flexibility - Full control over layout, colors, fonts
โ
Quick Deployment - Drag all equipment at once
โ
Easy Updates - Modify include files, affects all rows
โ
No Manual ORD Editing - Automatic variable substitution
โ
Alternating Colors - Easy to implement with two include files
โ
Scalable - Works for 5 pieces of equipment or 500
PX Include Variables: Complete Workflow
Planning Phase
Step 1: Identify Reusable Components
-
What elements repeat across multiple graphics?
-
Floor plan zone details?
-
Equipment schedule rows?
-
Navigation headers?
Step 2: Design Your Include
-
What widgets are needed?
-
What ORDs need to be configured?
-
What base component will be the variable?
Creation Phase
Step 1: Create Include File
-
Create PX file in
px/includes/folder -
Use canvas pane as root
-
Set scaling to None
-
Size appropriately
Step 2: Add Widgets
-
Copy from existing graphics, or
-
Create from scratch
Step 3: Convert ORDs to Variables
-
Replace base component paths with
$(variableName) -
Keep additional paths after variable
-
Remember leading slash on appended paths
Implementation Phase
Step 1: Select Base Components
-
From component tree
-
Single or multiple selection
Step 2: Drag and Drop
-
Drag onto PX editor
-
Make Widget Wizard appears
Step 3: Choose Include and Bind Variables
-
Select your include file
-
Bind displayed variables
-
Click OK
Step 4: Verify
-
Check variable property
-
Confirm ORD substitution worked correctly
-
Test functionality
Best Practices
Variable Naming
Do:
โ
Use descriptive names: $(zone), $(equipment), $(device)
โ
Use consistent names when possible (fewer variables = easier binding)
โ
Use lowercase with underscores: $(room_temp)
Don't:
โ Use random names like $(peanut_butter) in production
โ Use different variables for same base component (unless necessary)
โ Use spaces in variable names
File Organization
Do:
โ
Create px/includes/ folder for organization
โ
Use descriptive filenames: zone_detail.px, table_header.px
โ
Group related includes together
โ
Document what each include is for
Don't:
โ Scatter include files throughout station
โ Use vague names like include1.px, include2.px
Canvas Sizing
Do:
โ
Size canvas exactly to content
โ
Test include in target files to verify sizing
โ
Set scaling to None
Don't:
โ Make canvas too large (wastes space)
โ Make canvas too small (content cut off)
โ Leave scaling on (causes issues when embedded)
Variable Design
Do:
โ
Use same variable for all bindings with same base
โ
Only create additional variables when base differs
โ
Document which variable maps to what
Don't:
โ Create unnecessary variables
โ Use different variables for same base (makes binding tedious)
Troubleshooting
Variables Not Showing in Wizard
Problem: Variables section is empty in Make Widget Wizard
Possible Causes:
-
Variable syntax incorrect (missing
$, parentheses) -
PX include file not saved
-
Wrong file selected
Solution:
-
Verify variable syntax:
$(variableName) -
Save include file
-
Select correct include file
ORDs Not Resolving Correctly
Problem: Bindings don't work after using include
Possible Causes:
-
Missing forward slash in appended path
-
Incorrect variable substitution
-
Base component doesn't match expected structure
Solution:
-
Check for leading slash:
$(var)/points/Temp -
Verify ORD structure in include file
-
Confirm dragged component has expected points/paths
Include Appears But Content Wrong
Problem: PX include widget appears but shows wrong data
Possible Causes:
-
Variables bound to wrong components
-
Variable names mismatched
-
Include file updated but not refreshed
Solution:
-
Check Variables property - verify mappings
-
Ensure variable names match between definition and binding
-
Refresh/reload PX view
Key Takeaways
โ
PX Includes enable reusable UI components across multiple graphics
โ
Simple includes (no variables) work great for static content like headers
โ
Variable includes dramatically reduce configuration time for repeated elements
โ
Variable syntax: $(variableName) with optional /additional/path
โ
One variable per base component is the most efficient approach
โ
Use includes folder for organization
โ
Canvas pane root with scaling set to None
โ
Drag components (not include file) to use variables
โ
Make Widget Wizard handles variable binding automatically
โ
Massive time savings on large projects with many similar components
Coming in Part 2
The next video will cover:
-
More complex examples with PX includes
-
Using value bindings on PX include widgets
-
Dynamic substitutions based on station information
-
Advanced techniques and use cases
Quick Reference
Simple PX Include (No Variables)
1. Create include file with canvas pane root
2. Add content (labels, widgets, etc.)
3. Drag include file onto target PX
4. Position as needed
PX Include with Variables
1. Create include file with canvas pane root
2. Add widgets with variable ORDs: $(varName)/path
3. Select base component(s) from tree
4. Drag onto PX editor
5. Make Widget Wizard โ Include px file
6. Select include file
7. Bind variables
8. Click OK
Variable ORD Syntax
$(variableName) โ Base component only
$(variableName)/points/Temp โ Base + additional path
$(var1)/path/to/point โ Keep leading slash!
Presenter: James Johnson
Series:Niagara PRO TIPS
Topic:PX Includes - Part 1
Part:1 of 2
Key Concept:Using PX includes with variables to dramatically reduce configuration time and errors
YouTube: http://www.youtube.com/@TridiumInc