Skip to main content

Goal

Build a working C# console app that loads a published Speckle model, counts elements by category, and writes a CSV report you can open in Excel.

What you will build

A console application that:
  • Reads credentials and target IDs from environment variables
  • Loads the latest version of a model from Speckle Server
  • Groups the model’s objects by category
  • Writes model-health-report.csv with category names and counts

When to use this

Use this pattern when you need a first real automation — BIM QA summaries, quantity checks, or a starting point for door schedules and property audits. This is the recommended onboarding path before connector development or advanced architecture. The simplest path for most AEC automation scripts:
  1. Paste the one-time AddSpeckleSdk bootstrap (see Automate with scripts)
  2. Authenticate with a personal access token from SPECKLE_TOKEN
  3. Fetch the latest version with client.Version.GetVersions
  4. Load the version with Receive3
  5. Query model.Objects and read properties with GetString
  6. Write results to CSV with StreamWriter
Avoid dependency injection beyond the bootstrap, repository patterns, and custom abstractions until you have a script that runs end to end.
Updating a version of this tool written for Receive2 and Flatten()? See Migrate to 2026.9.

Prerequisites

  • .NET SDK installed
  • A personal access token from Speckle
  • A published model on Speckle Server (from a connector or prior publish)
  • Project ID and model ID from the Speckle web app URL: https://app.speckle.systems/projects/{projectId}/models/{modelId}
Create a console project and install the SDK. 2026.9.0-beta.7 is the current 2026.9 build; a later stable 2026.9.0 replaces the pin without changing the code:

Complete example

Complete example
Set environment variables before running:
You should see the version id, the number of categories written, and the top 10 categories with their counts.

How it works

Bootstrap. AddSpeckleSdk registers IOperations, IClientFactory, and IAccountFactory. You paste this once per app — see Automate with scripts. Authentication. IAccountFactory.CreateAccount builds an in-memory Account from your PAT. No local account database is required for scripts. Latest version. client.Version.GetVersions returns versions for a model; the API returns the newest first when limit is 1. Receive. Receive3 downloads the version’s bundle and returns a Model. using deletes the downloaded files when the script ends. Query. model.Objects is a flat list of every object in the version. GetString("category") reads the category whether the producer stored it as an instance property, a type property, or a root value. See Object model for how properties are stored. Report. Grouping by category produces a simple model health summary. Extend the same pattern for door schedules or property audits: filter with model.ObjectsWith("path"), read values with GetString / GetDouble, and follow relations such as obj.Level?.Name.

Common mistakes

Next steps

Object model

How properties and relations are stored

Relations

Group by level, host, material, or system

Migrate to 2026.9

Side-by-side changes for existing scripts
Last modified on October 19, 2026