The IFC Model Validator (validator.js
) allows you to validate
conditions on IFC entities and their properties using JavaScript
expressions.
This tool lets you:
- Query all instances of an IFC class (e.g.
IFCWINDOW
) - Filter specific properties using operators (
<=
,>=
,==
, etc.) - Validate a condition across all instances and generate a report
- Check specific IFC entities by their Express ID (e.g.
IFCWINDOW[#15]
)
-
Ensure your project is set up correctly using the ../README.md setup guide.
-
Execute the validator with:
yarn validator model.ifc "JSexpression"
-
The
<JSexpression>
is a JavaScript-executable condition to check against an IFC class or a specific instance.
<ClassName>[#OptionalID].<Property> <Operator> <Value>
<ClassName>
→ The IFC class (e.g.IFCWINDOW
,IFCDOOR
).[#OptionalID]
→ (Optional) A specific instance Express ID (e.g.[#15]
).<Property>
→ The property name of the entity (e.g.Height
,Width
).<Operator>
→ A JavaScript comparison operator (<
,<=
,>
,>=
,==
,!=
).<Value>
→ The value to compare against (number, boolean, or string).
Operator | Meaning |
---|---|
< |
Less than |
<= |
Less than or equal to |
> |
Greater than |
>= |
Greater than or equal to |
== |
Equal to (loose comparison) |
=== |
Strict equal (type-sensitive) |
!= |
Not equal |
!== |
Strict not equal |
yarn validator myModel.ifc "IFCWINDOW.Height <= 5"
yarn validator myModel.ifc "IFCWINDOW[#15].Height <= 5"
yarn validator myModel.ifc "IFCDOOR.Height > 2.1"
yarn validator myModel.ifc "IFCWINDOW.Width == 1.2"
yarn validator myModel.ifc 'IFCWINDOW.Name == "LivingRoomWindow"'
yarn validator myModel.ifc "IFCSITE"
After running a validation query, you will see a summary report in the terminal:
Validation Report for Query: IFCWINDOW.Height <= 5
✔️ IFCWINDOW[#12] → PASSED (Height: 4.8)
❌ IFCWINDOW[#23] → FAILED (Height: 5.5)
✔️ IFCWINDOW[#31] → PASSED (Height: 4.9)
✅ Total Passing: 2
❌ Total Failing: 1
This tool directly evaluates your query using JavaScript expressions (eval
).
Here’s what happens internally:
- Parses the query into:
- Class (
IFCWINDOW
) - Property (
Height
) - Operator (
<=
) - Value (
5
)
- Class (
- Finds all instances of
IFCWINDOW
in the IFC file. - Extracts their
Height
property. - Evaluates the condition dynamically using
eval()
:const condition = `4.8 <= 5`; // Example for one entity const result = eval(condition); // true or false
- Generates a pass/fail report.
- Works on all IFC classes (
IFCWALL
,IFCWINDOW
,IFCDOOR
, etc.). - Works for custom properties as long as they exist on the IFC entity.
- Use any valid JavaScript comparison operators.
- If a property does not exist, it is treated as
undefined
.
yarn validator myModel.ifc "IFCWINDOW.[Height] <= 5"
Error: "Invalid query format"
✅ Fix: Remove extra brackets:
yarn validator myModel.ifc "IFCWINDOW.Height <= 5"
yarn validator myModel.ifc "IFCWINDOW.NonExistentProp == 1"
Error: "Property 'NonExistentProp' not found on IFCWINDOW"
✅ Fix: Use an existing property like "IFCWINDOW.Height <= 5"
.
yarn validator myModel.ifc "IFCFAKECLASS.Height > 3"
Error: "IFC class 'IFCFAKECLASS' does not exist in this model"
✅ Fix: Ensure you're querying a valid IFC class.
- ✅ Pass a query to filter IFC entities by properties and values.
- ✅ Supports expressions using JavaScript operators (
<=
,>=
,==
, etc.). - ✅ Works on specific instances (e.g.,
IFCWINDOW[#15]
). - ✅ Returns a validation report of passing and failing instances.
- ✅ Handles missing properties gracefully.
- ✅ Interactive IFC model validation from the terminal. 🚀
yarn validator myModel.ifc "IFCDOOR.Height >= 2.1"
This CLI makes IFC validation intuitive, powerful, and scriptable—directly in JavaScript expressions. 🚀