Skip to content

Validate Revit PSET files with exact Revit parsing logic - catches entity case errors, invalid data types, and structural issues before export.

License

Notifications You must be signed in to change notification settings

byggstyrning/revit-pset-validator

Repository files navigation

Revit PSET Validator

CLI tool and MCP server for validating Revit Property Set (PSET) definition files

A straightforward validator that implements the exact parsing logic from Revit IFC source code (PropertyMap.cs) and checks for common issues. The tool works both as a standalone CLI and as an MCP server.

License: MIT Python 3.10+ GitHub

Features

  • Exact Revit Parsing Logic - Matches PropertyMap.cs behavior exactly
  • Critical Validation - Detects entity name case issues (IFCSPACE vs IfcSpace)
  • Comprehensive Checks - Validates data types, structure, duplicates, and more
  • CLI Tool - Standalone command-line interface
  • MCP Server - Model Context Protocol server for AI integration
  • Clear Error Messages - Line numbers and suggestions for fixes
  • JSON Output - Machine-readable output for automation

Quick Start

Installation

# Clone repository
git clone https://github.com/byggstyrning/revit-pset-validator.git
cd revit-pset-validator

# Install dependencies
pip install -e .

# Or install with dev dependencies
pip install -e ".[dev]"

Install from PyPI (when available)

pip install revit-pset-validator

CLI Usage

# Validate a PSET file
python -m pset_validator PSET-SPECIFIC.txt

# JSON output for automation
python -m pset_validator PSET-SPECIFIC.txt --format json

# Exit code on errors (for CI/CD)
python -m pset_validator PSET-SPECIFIC.txt --exit-code

# Treat warnings as errors
python -m pset_validator PSET-SPECIFIC.txt --warnings-as-errors --exit-code

MCP Server Usage (Cursor/Claude Desktop)

The FastMCP server can be used with Cursor or Claude Desktop. Add to your MCP configuration:

For Cursor:

  1. First, install the package:

    pip install -e .
  2. Then configure in Cursor settings → MCP servers:

    {
      "mcpServers": {
        "pset-validator": {
          "command": "python",
          "args": ["-m", "pset_validator.server"],
          "env": {}
        }
      }
    }
  3. Restart Cursor after adding the MCP server configuration.

Note: Make sure the python command points to the same Python environment where you installed the package. You can verify with:

python -c "import pset_validator; print('OK')"

For Claude Desktop: Add to claude_desktop_config.json:

{
  "mcpServers": {
    "pset-validator": {
      "command": "python",
      "args": ["-m", "pset_validator.server"],
      "env": {}
    }
  }
}

Or run standalone:

python -m pset_validator.server

Available MCP Tools:

  • validate_pset_file(file_path: str) - Validate a PSET file from disk
  • validate_pset_content(content: str) - Validate PSET content from string

Validation Rules

Critical Validations (Errors)

  1. Entity Name Case: Must be IfcSpace, not IFCSPACE (case-sensitive - critical!)
  2. Entity Format: Ifc + EntityName (proper camelCase)
  3. Property Set Structure: Correct format with tab-separated columns
  4. Data Types: Valid Revit data types (LABEL, TEXT, BOOLEAN, INTEGER, REAL, etc.)
  5. Required Fields: PropertySet line must have name, level (I/T), and entity list
  6. File Format: Proper tab-separated format for property lines

Additional Validations (Warnings)

  1. Duplicate Properties: Same property name within a property set
  2. Duplicate Property Sets: Same property set name for same entities
  3. Empty Property Sets: Property sets with no properties defined
  4. Missing Revit Parameters: Warn when Revit parameter column is empty
  5. Properties Outside PropertySet: Properties defined before PropertySet declaration

Example PSET File

# User Defined PropertySet Definition File
PropertySet:	BIP	I	IfcWall
	BSABe			LABEL		BSABe
	BSABwr			LABEL		BSABwr
	TypeID			LABEL

Example Output

Valid File

Validating: PSET-SPECIFIC.txt
Property Sets: 14
Properties: 185

============================================================
[OK] File is valid!

File with Errors and Warnings

Validating: PSET.txt
Property Sets: 6
Properties: 174

============================================================

[ERROR] Errors: 1
  ERROR: Line 2: Entity name 'IFCSPACE' uses wrong case (all uppercase)
    -> Use 'IfcSpace' instead of 'IFCSPACE'

[WARNING] Warnings: 1
  WARNING: Line 5: Property 'TypeID' missing Revit parameter mapping
    -> Add Revit parameter name in third column (optional but recommended)

============================================================

Development

Running Tests

# Run all tests
pytest tests/ -v

# Run with coverage
pytest tests/ --cov=src/pset_validator --cov-report=html

# Run specific test file
pytest tests/unit/test_parser.py -v

Code Formatting

# Format code
black src/ tests/

# Lint code
ruff check src/ tests/

Project Structure

revit-pset-validator/
├── src/
│   └── pset_validator/
│       ├── __init__.py
│       ├── __main__.py          # CLI entry point
│       ├── server.py            # FastMCP server (MCP mode)
│       ├── validator.py         # Core validation logic
│       ├── parser.py            # PSET file parsing (matches PropertyMap.cs)
│       └── models.py            # Pydantic models for validation results
├── tests/
│   ├── resources/               # Test resources
│   │   ├── DefaultUserDefinedParameterSets.txt  # Official Autodesk template
│   │   └── test_sample.pset.txt                 # Test PSET file
│   ├── unit/
│   │   ├── test_parser.py
│   │   ├── test_validator.py
│   │   └── test_models.py
│   └── integration/
│       └── test_cli.py
├── pyproject.toml
└── README.md

Parsing Logic

The parser implements the exact logic from Revit IFC PropertyMap.cs (lines 327-393):

  1. Line Processing: Trim leading spaces/tabs, skip empty lines and comments
  2. PropertySet Line: Case-insensitive "PropertySet:" prefix, at least 4 tab-separated parts
  3. Property Line: At least 2 tab-separated parts, only processed inside PropertySet block
  4. Entities: Separated by comma, semicolon, or space
  5. Properties Outside PropertySet: Silently skipped (not errors)

Supported Data Types

LABEL, TEXT, BOOLEAN, INTEGER, REAL, AREA, VOLUME, POSITIVELENGTH, LENGTH, IDENTIFIER, THERMALTRANSMITTANCE, COUNT, CURRENCY, ELECTRICALCURRENT, FORCE, FREQUENCY, ILLUMINANCE, LOGICAL, LUMINOUSFLUX, NORMALISEDRATIO, PLANEANGLE, POSITIVEPLANEANGLE, POSITIVERATIO, POWER, PRESSURE, RATIO, THERMODYNAMICTEMPERATURE, VOLUMETRICFLOWRATE, COLORTEMPERATURE, ELECTRICALEFFICACY, ELECTRICALVOLTAGE, CLASSIFICATIONREFERENCE

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - see LICENSE file for details.

References

Related Projects

  • revit-ifc - Official Autodesk Revit IFC exporter source code

About

Validate Revit PSET files with exact Revit parsing logic - catches entity case errors, invalid data types, and structural issues before export.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages