← Inbox

C3D-0331 · Read layouts + title block border geometry before notching the top-left corner [C3D-NOTCHREAD] done

Read-only. Lists every layout with its media/paper range and block references, then dumps the SS_BLOCK* definitions: entity census by type+layer, every line over 3in with exact coordinates and layer, and any long polylines with their vertices. This locates the border rectangle(s) that must be reshaped for a 3x3 clerk box.

Script file
C3D-0331.cs
Target
260714 - 285 Huckaby Rd R2.dwg · paper space
Author
claude
Approved
yes · auto-auth
Timeout
120s

C# payload

// Read every layout, its block references, and the full geometry of the title block definition
// so the border rectangle(s) can be located exactly before anything is edited.
Log("drawing: " + Db.Filename);

var lm = LayoutManager.Current;
var bt = (BlockTable)Tx.GetObject(Db.BlockTableId, OpenMode.ForRead);

Log("--- layouts ---");
var dict = (DBDictionary)Tx.GetObject(Db.LayoutDictionaryId, OpenMode.ForRead);
foreach (DBDictionaryEntry de in dict) {
    if (de.Key == "Model") continue;
    var lay = (Layout)Tx.GetObject(de.Value, OpenMode.ForRead);
    var btr = (BlockTableRecord)Tx.GetObject(lay.BlockTableRecordId, OpenMode.ForRead);
    int ents = 0; var blocks = new List<string>();
    foreach (ObjectId id in btr) {
        ents++;
        var br = Tx.GetObject(id, OpenMode.ForRead) as BlockReference;
        if (br != null) {
            var bd = (BlockTableRecord)Tx.GetObject(br.BlockTableRecord, OpenMode.ForRead);
            blocks.Add(string.Format("{0}@({1:F3},{2:F3}) sc({3:F3},{4:F3}) rot={5:F1}",
                bd.Name, br.Position.X, br.Position.Y, br.ScaleFactors.X, br.ScaleFactors.Y,
                br.Rotation*180.0/Math.PI));
        }
    }
    Log(string.Format("LAYOUT \"{0}\"  tab={1}  entities={2}", lay.LayoutName, lay.TabOrder, ents));
    foreach (var b in blocks) Log("     block: " + b);

    // paper range in layout coords
    var ps = lay.PlotPaperSize; var pm = lay.PlotPaperMargins;
    double pw = ps.X/25.4, ph = ps.Y/25.4;
    double ml = pm.MinPoint.X/25.4, mb = pm.MinPoint.Y/25.4;
    Log(string.Format("     media=\"{0}\" paper={1:F3}x{2:F3}in  margins L{3:F3} B{4:F3}  -> paper x {5:F3}..{6:F3}  y {7:F3}..{8:F3}",
        lay.CanonicalMediaName, pw, ph, ml, mb, -ml, -ml+pw, -mb, -mb+ph));
}

Log("");
Log("--- title block definitions (SS_BLOCK*) ---");
foreach (ObjectId bid in bt) {
    var bd = (BlockTableRecord)Tx.GetObject(bid, OpenMode.ForRead);
    if (bd.Name.IndexOf("SS_BLOCK", StringComparison.OrdinalIgnoreCase) < 0) continue;
    int n = 0; foreach (ObjectId x in bd) n++;
    Log(string.Format("BLOCK \"{0}\"  entities={1}", bd.Name, n));

    // every Line, with layer - the border rectangle is in here
    var byLayer = new Dictionary<string,int>();
    foreach (ObjectId eid in bd) {
        var e = Tx.GetObject(eid, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
        if (e == null) continue;
        string k = e.GetType().Name + " on " + e.Layer;
        if (!byLayer.ContainsKey(k)) byLayer[k]=0;
        byLayer[k]++;
    }
    foreach (var kv in byLayer) Log(string.Format("     {0,-42} x{1}", kv.Key, kv.Value));

    // long lines only - these are the border
    Log("     --- lines longer than 3in ---");
    foreach (ObjectId eid in bd) {
        var ln = Tx.GetObject(eid, OpenMode.ForRead) as Line;
        if (ln == null) continue;
        if (ln.Length < 3.0) continue;
        Log(string.Format("     LINE [{0}] ({1,9:F4},{2,9:F4}) -> ({3,9:F4},{4,9:F4})  len={5,8:F4}  layer={6}",
            ln.Handle, ln.StartPoint.X, ln.StartPoint.Y, ln.EndPoint.X, ln.EndPoint.Y, ln.Length, ln.Layer));
    }
    // polylines too, in case the border is one closed pline
    foreach (ObjectId eid in bd) {
        var pl = Tx.GetObject(eid, OpenMode.ForRead) as Polyline;
        if (pl == null) continue;
        if (pl.Length < 10.0) continue;
        Log(string.Format("     PLINE [{0}] verts={1} closed={2} len={3:F4} layer={4}",
            pl.Handle, pl.NumberOfVertices, pl.Closed, pl.Length, pl.Layer));
        for (int i=0;i<pl.NumberOfVertices;i++) {
            var p = pl.GetPoint2dAt(i);
            Log(string.Format("           v{0}: ({1,9:F4},{2,9:F4}) bulge={3:F4}", i, p.X, p.Y, pl.GetBulgeAt(i)));
        }
    }
}

Result

Status
success
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260714 - 285 Huckaby Rd, Brooks, GA 30205, USA\260714 - 285 Huckaby Rd R2.dwg
Message
Executed C3D-0331 (0 entities touched).
Entities
Duration
640 ms
Civil 3D
25.0.0.0

Log

drawing: C:\Users\sanja\OneDrive\_SurveyDisco\260714 - 285 Huckaby Rd, Brooks, GA 30205, USA\260714 - 285 Huckaby Rd R2.dwg
--- layouts ---
LAYOUT "11X17"  tab=1  entities=142
     block: SS_LEGEND@(10.818,13.153) sc(1.000,1.000) rot=0.0
     block: SS_BLOCK_11X17@(10.815,0.287) sc(1.000,1.000) rot=0.0
     media="ANSI_full_bleed_B_(11.00_x_17.00_Inches)" paper=11.000x17.000in  margins L0.000 B0.000  -> paper x -0.000..11.000  y -0.000..17.000
LAYOUT "17X11"  tab=3  entities=140
     block: SS_BLOCK_17X11@(16.670,0.330) sc(1.000,1.000) rot=0.0
     block: SS_LEGEND@(16.553,1.111) sc(1.000,1.000) rot=0.0
     block: SCALE200@(13.054,0.738) sc(1.000,1.000) rot=0.0
     media="ANSI_full_bleed_B_(17.00_x_11.00_Inches)" paper=17.000x11.000in  margins L0.000 B0.000  -> paper x -0.000..17.000  y -0.000..11.000
LAYOUT "HOUSEDIM"  tab=2  entities=338
     block: Water Valve@(0.504,14.157) sc(0.698,0.698) rot=0.0
     block: Catch Basin@(0.504,14.345) sc(1.250,1.250) rot=0.0
     block: Drainage MH@(0.504,14.029) sc(1.000,1.000) rot=0.0
     block: Existing Hyd@(0.504,13.895) sc(0.723,0.723) rot=0.0
     block: STA@(0.504,13.702) sc(0.083,0.083) rot=0.0
     media="ANSI_full_bleed_B_(11.00_x_17.00_Inches)" paper=11.000x17.000in  margins L0.000 B0.000  -> paper x -0.000..11.000  y -0.000..17.000
LAYOUT "Layout1"  tab=4  entities=2
     media="ANSI_full_bleed_B_(17.00_x_11.00_Inches)" paper=17.000x11.000in  margins L0.000 B0.000  -> paper x -0.000..17.000  y -0.000..11.000

--- title block definitions (SS_BLOCK*) ---
BLOCK "SS_BLOCK_11X17"  entities=109
     Viewport on BLOCK_TB2                      x1
     Line on BLOCK_TB2                          x85
     MText on BLOCK_TB2                         x1
     DBText on BLOCK_TB2                        x8
     AttributeDefinition on BLOCK_TB2           x10
     MText on BLOCK_NOTES_FLOOD                 x1
     AttributeDefinition on BLOCK_NOTES_FLOOD   x3
     --- lines longer than 3in ---
     LINE [20ADF] ( -10.6097,  16.4339) -> (  -0.0433,  16.4339)  len= 10.5664  layer=BLOCK_TB2
     LINE [20AE0] ( -10.6497,  16.4772) -> (   0.0000,  16.4772)  len= 10.6497  layer=BLOCK_TB2
     LINE [20AE4] ( -10.1979,   1.7811) -> (  -2.4547,   1.7797)  len=  7.7432  layer=BLOCK_TB2
     LINE [20AE5] ( -10.1979,   1.5113) -> (  -2.4547,   1.5100)  len=  7.7432  layer=BLOCK_TB2
     LINE [20AE6] ( -10.1980,   1.2415) -> (  -2.4547,   1.2402)  len=  7.7433  layer=BLOCK_TB2
     LINE [20AE7] ( -10.1980,   0.9717) -> (  -2.4547,   0.9704)  len=  7.7433  layer=BLOCK_TB2
     LINE [20AE8] ( -10.1980,   2.0509) -> (  -2.5806,   2.0509)  len=  7.6174  layer=BLOCK_TB2
     LINE [20AEC] ( -10.1980,   2.7105) -> (  -0.0433,   2.7105)  len= 10.1547  layer=BLOCK_TB2
     LINE [20B31] (  -6.8131,   0.0433) -> (  -0.0414,   0.0433)  len=  6.7717  layer=BLOCK_TB2
     LINE [20B32] (  -0.0433,   2.7105) -> ( -10.1980,   2.7105)  len= 10.1547  layer=BLOCK_TB2
     LINE [20B33] (   0.0000,   0.0000) -> (   0.0000,   6.8827)  len=  6.8827  layer=BLOCK_TB2
     LINE [20B34] (  -0.0433,   0.0433) -> (  -0.0433,  16.4339)  len= 16.3905  layer=BLOCK_TB2
     LINE [20B35] ( -10.6497,   0.0000) -> (   0.0000,   0.0000)  len= 10.6497  layer=BLOCK_TB2
     LINE [20B36] ( -10.6497,  16.4772) -> ( -10.6497,   0.0000)  len= 16.4772  layer=BLOCK_TB2
     LINE [20B3E] (  -0.0000,   6.8827) -> (  -0.0000,  13.7654)  len=  6.8827  layer=BLOCK_TB2
BLOCK "SS_BLOCK_11X17 (1)"  entities=106
     Viewport on BLOCK_TB2                      x1
     Line on BLOCK_TB2                          x85
     MText on BLOCK_TB2                         x1
     DBText on BLOCK_TB2                        x9
     AttributeDefinition on BLOCK_TB2           x10
     --- lines longer than 3in ---
     LINE [1FEEA] ( -10.6097,  16.4339) -> (  -0.0433,  16.4339)  len= 10.5664  layer=BLOCK_TB2
     LINE [1FEEB] ( -10.6497,  16.4772) -> (   0.0000,  16.4772)  len= 10.6497  layer=BLOCK_TB2
     LINE [1FEEE] ( -10.1979,   1.7811) -> (  -2.4547,   1.7797)  len=  7.7432  layer=BLOCK_TB2
     LINE [1FEEF] ( -10.1979,   1.5113) -> (  -2.4547,   1.5100)  len=  7.7432  layer=BLOCK_TB2
     LINE [1FEF0] ( -10.1980,   1.2415) -> (  -2.4547,   1.2402)  len=  7.7433  layer=BLOCK_TB2
     LINE [1FEF1] ( -10.1980,   0.9717) -> (  -2.4547,   0.9704)  len=  7.7433  layer=BLOCK_TB2
     LINE [1FEF2] ( -10.1980,   2.0509) -> (  -2.5806,   2.0509)  len=  7.6174  layer=BLOCK_TB2
     LINE [1FEF6] ( -10.1980,   2.7105) -> (  -0.0433,   2.7105)  len= 10.1547  layer=BLOCK_TB2
     LINE [1FF3A] (  -6.8131,   0.0433) -> (  -0.0414,   0.0433)  len=  6.7717  layer=BLOCK_TB2
     LINE [1FF3B] (  -0.0433,   2.7105) -> ( -10.1980,   2.7105)  len= 10.1547  layer=BLOCK_TB2
     LINE [1FF3C] (   0.0000,   0.0000) -> (   0.0000,   6.8827)  len=  6.8827  layer=BLOCK_TB2
     LINE [1FF3D] (  -0.0433,   0.0433) -> (  -0.0433,  16.4339)  len= 16.3905  layer=BLOCK_TB2
     LINE [1FF3E] ( -10.6497,   0.0000) -> (   0.0000,   0.0000)  len= 10.6497  layer=BLOCK_TB2
     LINE [1FF3F] ( -10.6497,  16.4772) -> ( -10.6497,   0.0000)  len= 16.4772  layer=BLOCK_TB2
     LINE [1FF45] (  -0.0000,   6.8827) -> (  -0.0000,  13.7654)  len=  6.8827  layer=BLOCK_TB2
BLOCK "SS_BLOCK_11X17 (2)"  entities=106
     Viewport on BLOCK_TB2                      x1
     Line on BLOCK_TB2                          x85
     MText on BLOCK_TB2                         x1
     DBText on BLOCK_TB2                        x9
     AttributeDefinition on BLOCK_TB2           x10
     --- lines longer than 3in ---
     LINE [1FF6D] ( -10.6097,  16.4339) -> (  -0.0433,  16.4339)  len= 10.5664  layer=BLOCK_TB2
     LINE [1FF6E] ( -10.6497,  16.4772) -> (   0.0000,  16.4772)  len= 10.6497  layer=BLOCK_TB2
     LINE [1FF71] ( -10.1979,   1.7811) -> (  -2.4547,   1.7797)  len=  7.7432  layer=BLOCK_TB2
     LINE [1FF72] ( -10.1979,   1.5113) -> (  -2.4547,   1.5100)  len=  7.7432  layer=BLOCK_TB2
     LINE [1FF73] ( -10.1980,   1.2415) -> (  -2.4547,   1.2402)  len=  7.7433  layer=BLOCK_TB2
     LINE [1FF74] ( -10.1980,   0.9717) -> (  -2.4547,   0.9704)  len=  7.7433  layer=BLOCK_TB2
     LINE [1FF75] ( -10.1980,   2.0509) -> (  -2.5806,   2.0509)  len=  7.6174  layer=BLOCK_TB2
     LINE [1FF79] ( -10.1980,   2.7105) -> (  -0.0433,   2.7105)  len= 10.1547  layer=BLOCK_TB2
     LINE [1FFBD] (  -6.8131,   0.0433) -> (  -0.0414,   0.0433)  len=  6.7717  layer=BLOCK_TB2
     LINE [1FFBE] (  -0.0433,   2.7105) -> ( -10.1980,   2.7105)  len= 10.1547  layer=BLOCK_TB2
     LINE [1FFBF] (   0.0000,   0.0000) -> (   0.0000,   6.8827)  len=  6.8827  layer=BLOCK_TB2
     LINE [1FFC0] (  -0.0433,   0.0433) -> (  -0.0433,  16.4339)  len= 16.3905  layer=BLOCK_TB2
     LINE [1FFC1] ( -10.6497,   0.0000) -> (   0.0000,   0.0000)  len= 10.6497  layer=BLOCK_TB2
     LINE [1FFC2] ( -10.6497,  16.4772) -> ( -10.6497,   0.0000)  len= 16.4772  layer=BLOCK_TB2
     LINE [1FFC8] (  -0.0000,   6.8827) -> (  -0.0000,  13.7654)  len=  6.8827  layer=BLOCK_TB2
BLOCK "SS_BLOCK_11X17 (3)"  entities=106
     Viewport on BLOCK_TB2                      x1
     Line on BLOCK_TB2                          x85
     MText on BLOCK_TB2                         x1
     DBText on BLOCK_TB2                        x9
     AttributeDefinition on BLOCK_TB2           x10
     --- lines longer than 3in ---
     LINE [2001E] ( -10.6097,  16.4339) -> (  -0.0433,  16.4339)  len= 10.5664  layer=BLOCK_TB2
     LINE [2001F] ( -10.6497,  16.4772) -> (   0.0000,  16.4772)  len= 10.6497  layer=BLOCK_TB2
     LINE [20022] ( -10.1979,   1.7811) -> (  -2.4547,   1.7797)  len=  7.7432  layer=BLOCK_TB2
     LINE [20023] ( -10.1979,   1.5113) -> (  -2.4547,   1.5100)  len=  7.7432  layer=BLOCK_TB2
     LINE [20024] ( -10.1980,   1.2415) -> (  -2.4547,   1.2402)  len=  7.7433  layer=BLOCK_TB2
     LINE [20025] ( -10.1980,   0.9717) -> (  -2.4547,   0.9704)  len=  7.7433  layer=BLOCK_TB2
     LINE [20026] ( -10.1980,   2.0509) -> (  -2.5806,   2.0509)  len=  7.6174  layer=BLOCK_TB2
     LINE [2002A] ( -10.1980,   2.7105) -> (  -0.0433,   2.7105)  len= 10.1547  layer=BLOCK_TB2
     LINE [2006E] (  -6.8131,   0.0433) -> (  -0.0414,   0.0433)  len=  6.7717  layer=BLOCK_TB2
     LINE [2006F] (  -0.0433,   2.7105) -> ( -10.1980,   2.7105)  len= 10.1547  layer=BLOCK_TB2
     LINE [20070] (   0.0000,   0.0000) -> (   0.0000,   6.8827)  len=  6.8827  layer=BLOCK_TB2
     LINE [20071] (  -0.0433,   0.0433) -> (  -0.0433,  16.4339)  len= 16.3905  layer=BLOCK_TB2
     LINE [20072] ( -10.6497,   0.0000) -> (   0.0000,   0.0000)  len= 10.6497  layer=BLOCK_TB2
     LINE [20073] ( -10.6497,  16.4772) -> ( -10.6497,   0.0000)  len= 16.4772  layer=BLOCK_TB2
     LINE [20079] (  -0.0000,   6.8827) -> (  -0.0000,  13.7654)  len=  6.8827  layer=BLOCK_TB2
BLOCK "SS_BLOCK_17X11"  entities=43
     Line on BLOCK_TB2                          x22
     MText on BLOCK_TB2                         x1
     DBText on BLOCK_TB2                        x6
     AttributeDefinition on BLOCK_TB2           x10
     MText on BLOCK_NOTES_FLOOD                 x1
     AttributeDefinition on BLOCK_NOTES_FLOOD   x3
     --- lines longer than 3in ---
     LINE [21077] ( -16.2987,  10.2996) -> (  -0.0416,  10.2996)  len= 16.2570  layer=BLOCK_TB2
     LINE [21078] ( -16.3400,  10.3400) -> (   0.0000,  10.3400)  len= 16.3400  layer=BLOCK_TB2
     LINE [2107B] ( -16.2966,   1.6742) -> (  -8.8540,   1.6730)  len=  7.4426  layer=BLOCK_TB2
     LINE [2107C] ( -16.2967,   1.4206) -> (  -8.8540,   1.4194)  len=  7.4426  layer=BLOCK_TB2
     LINE [2107D] ( -16.2967,   1.1670) -> (  -8.8540,   1.1658)  len=  7.4427  layer=BLOCK_TB2
     LINE [2107E] ( -16.2967,   0.9134) -> (  -8.8540,   0.9122)  len=  7.4427  layer=BLOCK_TB2
     LINE [2107F] ( -16.2967,   1.9278) -> (  -8.9751,   1.9278)  len=  7.3217  layer=BLOCK_TB2
     LINE [21083] ( -16.2967,   2.5478) -> (  -6.5363,   2.5478)  len=  9.7604  layer=BLOCK_TB2
     LINE [21086] ( -16.2987,  10.2996) -> ( -16.2967,   0.0407)  len= 10.2589  layer=BLOCK_TB2
     LINE [21088] ( -16.2967,   0.0407) -> (  -0.0416,   0.0407)  len= 16.2551  layer=BLOCK_TB2
     LINE [21089] (  -6.5363,   2.5478) -> ( -16.2967,   2.5478)  len=  9.7604  layer=BLOCK_TB2
     LINE [2108A] (   0.0000,   0.0000) -> (   0.0000,  10.3400)  len= 10.3400  layer=BLOCK_TB2
     LINE [2108B] (  -0.0416,   0.0407) -> (  -0.0416,  10.2996)  len= 10.2589  layer=BLOCK_TB2
     LINE [2108C] ( -16.3400,   0.0000) -> (   0.0000,   0.0000)  len= 16.3400  layer=BLOCK_TB2
     LINE [2108D] ( -16.3400,  10.3400) -> ( -16.3400,   0.0000)  len= 10.3400  layer=BLOCK_TB2
     LINE [21093] (  -0.0000,   6.4698) -> (  -0.0000,  10.2996)  len=  3.8298  layer=BLOCK_TB2

Notes

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

No notes yet.