CODEX README — HAPI Obsidian Foundation

Purpose

This file is the recommended entry point for Codex or another coding agent working on the HAPI Project.

The goal is to provide enough project context to understand the HAPI business logic without repeatedly attaching the PDF user manual.

What HAPI Is

HAPI stands for HyD Automated Plotting Interface. It is a Civil 3D workflow originally implemented as Dynamo scripts for:

  • survey data exchange
  • point data import and export
  • migration from legacy DGN/DWG sources
  • survey plan drafting
  • plan production
  • Existing Conditions Modelling (ECM)

The long-term project direction is to migrate the Dynamo workflow into a structured, testable, and maintainable PythonNet3 / C# framework for Autodesk Civil 3D.

Read These Files First

Read the notes in this order:

  1. 00_Index.md
  2. 01_System_Overview/HAPI_System_Overview.md
  3. 03_Core_Concepts/Point_Code.md
  4. 03_Core_Concepts/Feature_Code.md
  5. 03_Core_Concepts/Feature_Type.md
  6. 03_Core_Concepts/Point_Code_Grouping_Rules.md
  7. 03_Core_Concepts/Rectangle_Fitting_Rules.md
  8. 03_Core_Concepts/Style_Code.md
  9. 06_Code_Reference/Feature_Catalogue.md
  10. 06_Code_Reference/Global_Configuration.md

Source Priority

Use this priority order when sources conflict:

PrioritySourceTreatment
1User-confirmed correctionsHighest priority where explicit.
2HAPI User Manual.pdfOfficial workflow and terminology.
3HAPI Quick Start Guide.pdfVisual and explanatory supplement.
4FeatureCatalogue.json / GlobalConfiguration.jsonCurrent executable configuration.
5Old Markdown specificationsImplementation notes, not automatically canonical.

Confirmed Corrections

TopicCorrect Rule
Shrink to Fit rectangle scoringUse Minimum Perimeter. Do not use minimum area, even though the manual says smallest area.

Core Concepts

Point Code

A Point Code defines the surveyed feature and controls geometric processing.

Point Code = Feature Code + optional Segment Type Indicator + optional Numeric Suffix + optional Supplementary Suffix

Important examples:

CodeMeaning
KX01Kerb Bottom, straight segment, cluster 01.
KC01Kerb Bottom, curve segment, cluster 01.
CP3Catch Pit using three points for enclosing rectangle construction.
FB02Flower Bed cluster 02, forming an irregular polygon.
KX01GKerb Bottom cluster 01 with compound Grating suffix.

Feature Type

Supported routing types:

Feature TypeMeaning
1POINTSingle-coordinate placement.
2POINTTwo points define length and orientation.
LINEAROpen continuous line string.
POLYGONEnclosed or rectangle-derived shape.

Numeric Suffix

Digit CountTypeMeaning
1Sizing NumberDefines the exact number of points for rectangle construction.
2Clustering NumberLinks non-sequential related records.

Rectangle Fitting

Use two modes:

ModeRule
Best-fitSelect the truest 90-degree surveyed corner and align the rectangle to it.
Shrink to FitTest candidate orientations and select the lowest Width + Height score.

Always apply left-first orientation stabilisation after rectangle generation.

Style Code

Style Code is used for ECM appearance and object style resolution. Point Code defines geometry and processing; Style Code defines physical appearance and ECM style selection.

Implementation Constraints

Naming

Use PascalCase for planned functions and methods.

Examples:

  • ParseSurveyData
  • ParsePointCode
  • ResolveFeatureCode
  • ResolveFeatureType
  • CalculateBestFitRectangle
  • CalculateShrinkToFitRectangle
  • CreateCogoPoints
  • BuildLayerMapping

Environment

Target environment:

  • Autodesk Civil 3D 2026+
  • Civil 3D 2027 compatibility where relevant
  • Dynamo for Civil 3D during migration
  • PythonNet3
  • CPython 3.11
  • AutoCAD .NET API
  • Civil 3D .NET API
  • Future native C# Civil 3D plugin path

Architecture

Obsidian is the knowledge-management layer, not the automation engine.

PythonNet3/C# code should keep pure business logic testable outside Civil 3D where possible. Civil 3D API-dependent code should be isolated behind clear integration layers.

Do Not Do

  • Do not invent unsupported HAPI rules.
  • Do not treat old Markdown files as higher authority than the manual unless there is a user-confirmed correction.
  • Do not use minimum area for Shrink to Fit.
  • Do not hard-code Feature Catalogue values where they can be loaded from configuration.
  • Do not mix raw source extraction with final structured notes.

Current Knowledge Base Status

This first batch defines the foundation layer:

  • HAPI system overview
  • Point Code anatomy
  • Feature Code and Feature Type
  • Numeric suffix rules
  • grouping logic
  • rectangle fitting rules
  • Style Code basics
  • Feature Catalogue reference
  • Global Configuration reference

Next recommended batches:

  1. file format notes for CSV, PT2, DTA, and XYZ
  2. SurveyRecord data model
  3. A-series script documentation
  4. PythonNet3 code generation rules
  5. pure Python test harness notes
  6. C# migration architecture notes

Open Questions

  • Should curve Feature Codes such as KC be stored as raw FeatureCode = KC, or resolved to base FeatureCode = KX plus IsCurveSegment = True?
  • Should the misspelt configuration key FriendlyNeighborhoodThreshould be preserved or migrated with alias support?
  • Should Supplementary Suffix rules live in FeatureCatalogue.json or a separate compound feature catalogue?
Built with LogoFlowershow