← Inbox

C3D-SHEETDUMP · Dump 22X17 C sheet contents error

Read-only: every MText, DBText, Line and other entity on the 22X17 C sheet with positions, heights and content.

Script file
C3D-SHEETDUMP.cs
Target
active document · paper space
Author
claude
Approved
yes · auto-auth
Timeout
60s

C# payload

// READ-ONLY: dump every text + line on the 22X17 C sheet's cert layers, with positions, so the
// user's manual edits can be compared against what was generated.
const string LAYOUT = "22X17 C";
var layDict = (DBDictionary)Tx.GetObject(Db.LayoutDictionaryId, OpenMode.ForRead);
var layout  = (Layout)Tx.GetObject(layDict.GetAt(LAYOUT), OpenMode.ForRead);
var ps      = (BlockTableRecord)Tx.GetObject(layout.BlockTableRecordId, OpenMode.ForRead);

int mt = 0, dt = 0, ln = 0, other = 0;
foreach (ObjectId id in ps)
{
    var e = Tx.GetObject(id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
    if (e == null) continue;

    var m = e as MText;
    if (m != null)
    {
        mt++;
        var ex = m.GeometricExtents;
        Log("MTEXT h=" + e.Handle + " layer='" + e.Layer + "' at (" + m.Location.X.ToString("F2") + "," + m.Location.Y.ToString("F2") +
            ") th=" + m.TextHeight.ToString("F3") + " w=" + m.Width.ToString("F2") +
            " box=" + (ex.MaxPoint.X-ex.MinPoint.X).ToString("F2") + "x" + (ex.MaxPoint.Y-ex.MinPoint.Y).ToString("F2"));
        var c = m.Contents.Replace("\P", " | ");
        Log("   " + (c.Length > 260 ? c.Substring(0,260) + " ..." : c));
        continue;
    }
    var d = e as DBText;
    if (d != null)
    {
        dt++;
        Log("DBTEXT h=" + e.Handle + " layer='" + e.Layer + "' at (" + d.Position.X.ToString("F2") + "," + d.Position.Y.ToString("F2") +
            ") th=" + d.Height.ToString("F3") + "  >>> " + d.TextString);
        continue;
    }
    var l = e as Line;
    if (l != null)
    {
        ln++;
        Log("LINE   h=" + e.Handle + " layer='" + e.Layer + "' (" + l.StartPoint.X.ToString("F2") + "," + l.StartPoint.Y.ToString("F2") +
            ") -> (" + l.EndPoint.X.ToString("F2") + "," + l.EndPoint.Y.ToString("F2") + ") len=" + l.Length.ToString("F2"));
        continue;
    }
    other++;
    Log("OTHER  h=" + e.Handle + " " + e.GetType().Name + " layer='" + e.Layer + "'");
}
Log("counts: MText=" + mt + " DBText=" + dt + " Line=" + ln + " other=" + other);

Result

Status
error
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260619 - 3625 Stonewall Tell Rd, Atlanta, GA 30349, USA\260619 - 3625 Stonewall Tell Rd ROTATE.dwg
Message
Compile error: (22,37): error CS1009: Unrecognized escape sequence
Entities
Duration
3 ms
Civil 3D
25.0.0.0

Notes

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

No notes yet.