← Inbox

C3D-INSP2403B · Full VP-freeze + parcel-layer map (read-only) error

Per-viewport frozen-layer sets for 09/10/R4, and the layer each parcel + its area label sits on. For heroing Parcel #2 (1.593 ac) on paper 10.

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

C# payload

// READ-ONLY: full isolation + parcel-layer picture for hero planning.
// - each paper tab: for each non-paper viewport, list ALL per-VP frozen layers (full, not sampled)
// - Parcel #1 and #2: their layer, the layer of their area label, and their boundary segment count
using System;
using System.Linq;
using System.Collections.Generic;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.Civil.ApplicationServices;
using Autodesk.Civil.DatabaseServices;

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

// ---- full per-viewport frozen-layer sets per layout ----
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);
        Log($"== LAYOUT [{lay.LayoutName}] ==");
        int n = 0;
        foreach (ObjectId vid in lay.GetViewports())
        {
            var vp = tr.GetObject(vid, OpenMode.ForRead) as Viewport;
            if (vp == null || vp.Number == 1) continue;
            n++;
            var fl = vp.GetFrozenLayers();
            var names = new List<string>();
            if (fl != null)
                foreach (ObjectId lid in fl)
                    names.Add(((LayerTableRecord)tr.GetObject(lid, OpenMode.ForRead)).Name);
            names.Sort(StringComparer.OrdinalIgnoreCase);
            Log($"  VP#{vp.Number} scale=1/{(vp.CustomScale!=0?1.0/vp.CustomScale:0):0} frozenLayers({names.Count}): {(names.Count==0?"<none>":string.Join(", ", names))}");
        }
        if (n == 0) Log("  (no floating viewports)");
    }
    tr.Commit();
}

// ---- which layer does each parcel's geometry + area label sit on ----
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);
            double sf = p.Area;
            Log($"PARCEL #{p.Number} '{p.Name}' {sf/43560.0:0.000} ac  layer='{p.Layer}'");
            // area label layer/ids
            try {
                var alids = p.GetAreaLabelIds();
                foreach (ObjectId aid in alids)
                {
                    var al = tr.GetObject(aid, OpenMode.ForRead) as Entity;
                    Log($"    areaLabel: type={al.GetType().Name} layer='{al.Layer}'");
                }
                if (alids.Count == 0) Log("    areaLabel: <none>");
            } catch (System.Exception ex) { Log($"    areaLabel read note: {ex.Message}"); }
        }
    }
    tr.Commit();
}

Result

Status
error
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\251009 - 281 Maranatha Trail, Lawrenceville, GA 30045, USA\281 MARANATHA 2403\281 MARANTHA LOT 10.dwg
Message
Compile error: (57,31): error CS1061: 'Parcel' does not contain a definition for 'GetAreaLabelIds' and no accessible extension method 'GetAreaLabelIds' accepting a first argument of type 'Parcel' could be found (are you missing a using directive or an assembly reference?); (60,69): error CS0104: 'Entity' is an ambiguous reference between 'Autodesk.AutoCAD.DatabaseServices.Entity' and 'Autodesk.Civil.DatabaseServices.Entity'; (63,21): error CS0019: Operator '==' cannot be applied to operands of type 'method group' and 'int'
Entities
Duration
365 ms
Civil 3D
25.0.0.0

Notes

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

No notes yet.