← Inbox

C3D-0054 · READ-ONLY: re-check every manhole point and its layer [MH-RECHECK] error

Lists every CogoPoint whose description mentions MH/SSMH/MANHOLE individually with point number, description, layer, style and coordinates, plus a per-layer tally. No changes.

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

C# payload

// READ-ONLY. Re-check every manhole point after the user's edits.
//
// Anything whose description mentions MH / SSMH / MANHOLE, listed individually with point number,
// description, layer, style and coordinates - so a wrong layer is visible per point rather than
// only per description group. Nothing is modified.
var ms = (BlockTableRecord)Tx.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(Db), OpenMode.ForRead);

Func<Func<string>, string> safe = f => { try { return f(); } catch (System.Exception ex) { return "<" + ex.GetType().Name + ">"; } };

var rows = new List<string>();
var byLayer = new Dictionary<string,int>();
int n = 0;

foreach (ObjectId id in ms) {
    CogoPoint cp = null;
    try { cp = Tx.GetObject(id, OpenMode.ForRead) as CogoPoint; } catch { continue; }
    if (cp == null) continue;

    string d = safe(() => (cp.RawDescription ?? "")).Trim();
    string u = d.ToUpper();
    if (u.IndexOf("MH") < 0 && u.IndexOf("MANHOLE") < 0) continue;
    n++;

    string lay = safe(() => cp.Layer);
    if (!byLayer.ContainsKey(lay)) byLayer[lay] = 0;
    byLayer[lay]++;

    rows.Add(String.Format("  pt {0,-6} {1,-22} layer={2,-24} style={3,-18} {4}",
        safe(() => cp.PointNumber.ToString()),
        d,
        lay,
        safe(() => cp.StyleName),
        safe(() => String.Format("{0:F2},{1:F2}", cp.Easting, cp.Northing))));
}

rows.Sort();
Log("=== ALL MANHOLE POINTS (" + n + ") ===");
foreach (var r in rows) Log(r);

Log("");
Log("=== by layer ===");
foreach (var kv in byLayer) Log("  " + kv.Key + " : " + kv.Value);

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: (32,23): error CS1061: 'CogoPoint' does not contain a definition for 'StyleName' and no accessible extension method 'StyleName' accepting a first argument of type 'CogoPoint' could be found (are you missing a using directive or an assembly reference?)
Entities
Duration
396 ms
Civil 3D
25.0.0.0

Notes

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

No notes yet.