← Inbox

C3D-0033 · READ-ONLY: enumerate parcels, areas and area labels [PARCEL-AREA] error

Why does the 30' S.S.E. parcel label 12600.25 sq ft when the outline measures 24157.56? Lists every site/parcel with area, perimeter and segment count, and every parcel area label with the parcel it actually points at. No changes.

Script file
C3D-0033.cs
Target
260612 · model space
Author
claude
Approved
yes · reviewer
Timeout
180s

C# payload

// READ-ONLY. Enumerate every site, every parcel in each site, and every parcel's area /
// perimeter / segment count, plus any area label attached to it.
//
// The question: the 30' S.S.E. parcel labels 12600.25 sq ft but the enclosed shape measures
// 24157.56. Either the label belongs to a different parcel than the outline (site topology
// split the easement at a crossing), or there are more parcels here than expected.
// Nothing is modified.
var civil = CivilApplication.ActiveDocument;

Log("SITES: " + civil.GetSiteIds().Count);
foreach (ObjectId sid in civil.GetSiteIds()) {
    var site = (Site)Tx.GetObject(sid, OpenMode.ForRead);
    var pids = site.GetParcelIds();
    Log("");
    Log("SITE \"" + site.Name + "\"  parcels=" + pids.Count);
    foreach (ObjectId pid in pids) {
        var p = (Parcel)Tx.GetObject(pid, OpenMode.ForRead);
        double area = 0.0, per = 0.0;
        try { area = p.Area; } catch { }
        try { per = p.Perimeter; } catch { }
        int nseg = 0;
        try { nseg = p.GetParcelLoops()[0].Count; } catch { }
        Log(String.Format("  [{0}] \"{1}\"  num={2}  area={3:F2}  perim={4:F2}  segs={5}  layer={6}",
            p.ObjectId.Handle, p.Name, p.Number, area, per, nseg, p.Layer));
    }
}

// Area labels can live independently of the parcel they annotate.
int nlbl = 0;
var ms = (BlockTableRecord)Tx.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(Db), OpenMode.ForRead);
foreach (ObjectId id in ms) {
    var o = Tx.GetObject(id, OpenMode.ForRead);
    var pal = o as ParcelAreaLabel;
    if (pal == null) continue;
    nlbl++;
    string pname = "?";
    double parea = 0.0;
    try {
        var par = (Parcel)Tx.GetObject(pal.FeatureId, OpenMode.ForRead);
        pname = par.Name; parea = par.Area;
    } catch { }
    Log(String.Format("AREA LABEL [{0}] -> parcel \"{1}\" area={2:F2}  at {3:F2},{4:F2}",
        pal.ObjectId.Handle, pname, parea, pal.LabelLocation.X, pal.LabelLocation.Y));
}
Log("parcel area labels: " + nlbl);

Result

Status
error
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260613 - 5030 E Lake Pkwy, Stockbridge, GA 30281, USA\260612 - CSTORE WATER ABS 30.dwg
Message
Compile error: (20,23): error CS1061: 'Parcel' does not contain a definition for 'Perimeter' and no accessible extension method 'Perimeter' accepting a first argument of type 'Parcel' could be found (are you missing a using directive or an assembly reference?); (22,24): error CS1061: 'Parcel' does not contain a definition for 'GetParcelLoops' and no accessible extension method 'GetParcelLoops' accepting a first argument of type 'Parcel' could be found (are you missing a using directive or an assembly reference?)
Entities
Duration
347 ms
Civil 3D
25.0.0.0

Notes

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

No notes yet.