← Inbox

C3D-260619-FRAME · Read title block frame upper-left done

Read-only: SS_BLOCK_22X17 reference transform and the frame lines/polylines near the upper-left corner, in both block and sheet coordinates, to plan a 3x3 notch for the clerk box.

Script file
C3D-260619-FRAME.cs
Target
260619 · paper space
Author
claude
Approved
yes · reviewer
Timeout
180s

C# payload

// READ-ONLY: the title-block frame geometry near the upper-left, so a 3x3 notch can be cut for
// the clerk recording box at the true page corner (0,14)-(3,17).
// The frame is inside the SS_BLOCK_22X17 block definition, so this reports what is in the
// definition near that corner, in BLOCK coordinates and in SHEET coordinates.
const string LAYOUT = "22X17 C", BLK = "SS_BLOCK_22X17";

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);

foreach (ObjectId id in ps)
{
    var br = Tx.GetObject(id, OpenMode.ForRead) as BlockReference;
    if (br == null) continue;
    var def = (BlockTableRecord)Tx.GetObject(br.BlockTableRecord, OpenMode.ForRead);
    if (def.Name != BLK) continue;

    Log("BlockRef h=" + br.Handle + " at (" + br.Position.X.ToString("F3") + "," + br.Position.Y.ToString("F3") +
        ") scale=" + br.ScaleFactors.X.ToString("F4") + " rot=" + br.Rotation.ToString("F4"));
    var ext = br.GeometricExtents;
    Log("  reference extents (" + ext.MinPoint.X.ToString("F2") + "," + ext.MinPoint.Y.ToString("F2") + ")-(" +
        ext.MaxPoint.X.ToString("F2") + "," + ext.MaxPoint.Y.ToString("F2") + ")");

    var xform = br.BlockTransform;
    Log("  --- definition entities whose SHEET position is in the upper-left quadrant ---");
    foreach (ObjectId cid in def)
    {
        var ce = Tx.GetObject(cid, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
        if (ce == null) continue;

        var ln = ce as Line;
        if (ln != null)
        {
            var a = ln.StartPoint.TransformBy(xform);
            var b = ln.EndPoint.TransformBy(xform);
            bool near = (a.X < 6.0 || b.X < 6.0) && (a.Y > 12.0 || b.Y > 12.0);
            if (!near) continue;
            Log("    Line h=" + ce.Handle + " layer='" + ce.Layer + "'");
            Log("        block  (" + ln.StartPoint.X.ToString("F3") + "," + ln.StartPoint.Y.ToString("F3") + ") -> (" +
                ln.EndPoint.X.ToString("F3") + "," + ln.EndPoint.Y.ToString("F3") + ")");
            Log("        sheet  (" + a.X.ToString("F3") + "," + a.Y.ToString("F3") + ") -> (" +
                b.X.ToString("F3") + "," + b.Y.ToString("F3") + ")  len=" + ln.Length.ToString("F3"));
            continue;
        }
        var pl = ce as Polyline;
        if (pl != null)
        {
            bool near = false;
            for (int i = 0; i < pl.NumberOfVertices; i++)
            {
                var p = new Point3d(pl.GetPoint2dAt(i).X, pl.GetPoint2dAt(i).Y, 0).TransformBy(xform);
                if (p.X < 6.0 && p.Y > 12.0) { near = true; break; }
            }
            if (!near) continue;
            Log("    Polyline h=" + ce.Handle + " layer='" + ce.Layer + "' verts=" + pl.NumberOfVertices + " closed=" + pl.Closed);
            for (int i = 0; i < pl.NumberOfVertices; i++)
            {
                var v = pl.GetPoint2dAt(i);
                var p = new Point3d(v.X, v.Y, 0).TransformBy(xform);
                Log("        v" + i + " block(" + v.X.ToString("F3") + "," + v.Y.ToString("F3") + ")  sheet(" + p.X.ToString("F3") + "," + p.Y.ToString("F3") + ")");
            }
        }
    }
}

Result

Status
success
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260619 - 3625 Stonewall Tell Rd, Atlanta, GA 30349, USA\260619 - 3625 Stonewall Tell Rd ROTATE.dwg
Message
Executed C3D-260619-FRAME (0 entities touched).
Entities
Duration
1963 ms
Civil 3D
25.0.0.0

Log

BlockRef h=222EB at (21.754,0.261) scale=1.0000 rot=0.0000
  reference extents (0.25,0.26)-(21.75,16.74)
  --- definition entities whose SHEET position is in the upper-left quadrant ---
    Line h=222BD layer='BLOCK_TB2'
        block  (-21.461,16.434) -> (-0.043,16.434)
        sheet  (0.293,16.695) -> (21.711,16.695)  len=21.418
    Line h=222BE layer='BLOCK_TB2'
        block  (-21.509,16.477) -> (0.000,16.477)
        sheet  (0.246,16.739) -> (21.754,16.739)  len=21.509
    Line h=222D3 layer='BLOCK_TB2'
        block  (-21.509,16.477) -> (-21.509,0.000)
        sheet  (0.246,16.739) -> (0.246,0.261)  len=16.477
    Line h=222E6 layer='BLOCK_TB2'
        block  (-21.461,0.043) -> (-21.461,16.434)
        sheet  (0.293,0.305) -> (0.293,16.695)  len=16.391

Notes

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

No notes yet.