← Inbox

C3D-INSP2403E · Hero VP framing + candidate layers v2 (read-only) done

Parcel centroids vs each sheet's viewport view-center/height + hero-layer entity counts. Entity ambiguity fixed.

Script file
C3D-INSP2403E.cs
Target
active document · model space
Author
claude
Approved
yes · claude (read-only)
Timeout
60s

C# payload

// READ-ONLY: what does each hero viewport FRAME, and what's drawn there?
// For 09, 10, R4: the model-space view center+height each VP shows (so I know which parcel it frames),
// and the parcel centroids so I can tell which parcel each sheet is aimed at.
// Also: enumerate hero-candidate layers (SS-BOUNDARY_*) and count entities on each + which are visible.
using System;
using System.Linq;
using System.Collections.Generic;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.Civil.ApplicationServices;
using Autodesk.Civil.DatabaseServices;

var db = Db;
Log($"ACTIVE: {System.IO.Path.GetFileName(Doc.Name)}");

// parcel centroids (approx via extents center) so we can match VP view -> parcel
using (var tr = db.TransactionManager.StartTransaction())
{
    var cdoc = CivilDocument.GetCivilDocument(db);
    foreach (ObjectId sid in cdoc.GetSiteIds())
    {
        var site = (Site)tr.GetObject(sid, OpenMode.ForRead);
        foreach (ObjectId pid in site.GetParcelIds())
        {
            var p = (Parcel)tr.GetObject(pid, OpenMode.ForRead);
            try {
                var ext = p.GeometricExtents;
                var cx = (ext.MinPoint.X+ext.MaxPoint.X)/2; var cy=(ext.MinPoint.Y+ext.MaxPoint.Y)/2;
                Log($"PARCEL #{p.Number} {p.Area/43560.0:0.000}ac center=({cx:0.0},{cy:0.0}) w={(ext.MaxPoint.X-ext.MinPoint.X):0} h={(ext.MaxPoint.Y-ext.MinPoint.Y):0}");
            } catch (System.Exception ex) { Log($"PARCEL #{p.Number}: extents note {ex.Message}"); }
        }
    }
    tr.Commit();
}

// each layout's viewport view center + height (model units) => which parcel it's framed on
using (var tr = db.TransactionManager.StartTransaction())
{
    var ld = (DBDictionary)tr.GetObject(db.LayoutDictionaryId, OpenMode.ForRead);
    foreach (DBDictionaryEntry e in ld)
    {
        if (string.Equals(e.Key,"Model",StringComparison.OrdinalIgnoreCase)) continue;
        var lay = (Layout)tr.GetObject(e.Value, OpenMode.ForRead);
        foreach (ObjectId vid in lay.GetViewports())
        {
            var vp = tr.GetObject(vid, OpenMode.ForRead) as Viewport;
            if (vp == null || vp.Number == 1) continue;
            Log($"[{lay.LayoutName}] VP viewCenter=({vp.ViewCenter.X:0.0},{vp.ViewCenter.Y:0.0}) viewHeight={vp.ViewHeight:0} customScale={vp.CustomScale:0.000000}");
        }
    }
    tr.Commit();
}

// hero-candidate layers: entity counts on SS-BOUNDARY_* and BOUNDARY* (model space)
using (var tr = db.TransactionManager.StartTransaction())
{
    var want = new List<string>{"SS-BOUNDARY_CYAN","SS-BOUNDARY_RED","SS-BOUNDARY_R3","BOUNDARY"};
    var counts = want.ToDictionary(w=>w, w=>0, StringComparer.OrdinalIgnoreCase);
    var ms = (BlockTableRecord)tr.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForRead);
    foreach (ObjectId id in ms)
    {
        var ent = tr.GetObject(id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
        if (ent != null && counts.ContainsKey(ent.Layer)) counts[ent.Layer]++;
    }
    Log("HERO-CANDIDATE LAYER ENTITY COUNTS (model space):");
    foreach (var kv in counts) Log($"  {kv.Key}: {kv.Value}");
    tr.Commit();
}

Result

Status
success
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\251009 - 281 Maranatha Trail, Lawrenceville, GA 30045, USA\281 MARANATHA 2403\281 MARANTHA LOT 10.dwg
Message
Executed C3D-INSP2403E (0 entities touched).
Entities
Duration
375 ms
Civil 3D
25.0.0.0

Log

ACTIVE: 281 MARANTHA LOT 10.dwg
PARCEL #1 2.817ac center=(2359516.2,1425569.2) w=436 h=496
PARCEL #1 1.224ac center=(2358916.5,1425876.2) w=300 h=288
PARCEL #2 1.593ac center=(2358859.6,1425167.9) w=277 h=472
[09] VP viewCenter=(5.5,8.5) viewHeight=17 customScale=1.000000
[09] VP viewCenter=(2359580.6,1425541.7) viewHeight=1020 customScale=0.016667
[10] VP viewCenter=(6.4,9.9) viewHeight=11 customScale=1.000000
[10] VP viewCenter=(2359580.6,1425541.7) viewHeight=1020 customScale=0.016667
[R4] VP viewCenter=(5.5,8.5) viewHeight=17 customScale=1.000000
[R4] VP viewCenter=(2359580.6,1425541.7) viewHeight=1020 customScale=0.016667
HERO-CANDIDATE LAYER ENTITY COUNTS (model space):
  SS-BOUNDARY_CYAN: 6
  SS-BOUNDARY_RED: 11
  SS-BOUNDARY_R3: 1
  BOUNDARY: 14

Notes

What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.

No notes yet.