← Inbox

C3D-PSVERIFY · Verify landscape layout coherent (read-only) done

Every PS entity group's extents vs limits; flag anything past the paper.

Script file
C3D-PSVERIFY.cs
Target
active document · paper space
Author
claude
Approved
yes · claude (read-only)
Timeout
60s

C# payload

// READ-ONLY: confirm the landscape layout is coherent after the border rotate.
// Report every paper-space entity's extents relative to the layout limits — flag anything sticking out.
using System;
using System.Collections.Generic;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;

var db = Db;
using (var tr = db.TransactionManager.StartTransaction())
{
    var ld = (DBDictionary)tr.GetObject(db.LayoutDictionaryId, OpenMode.ForRead);
    Layout lay = null;
    foreach (DBDictionaryEntry e in ld)
    {
        var l = (Layout)tr.GetObject(e.Value, OpenMode.ForRead);
        if (string.Equals(l.LayoutName, "11X17", StringComparison.OrdinalIgnoreCase)) { lay = l; break; }
    }
    var lo = lay.Limits.MinPoint; var hi = lay.Limits.MaxPoint;
    Log($"limits ({lo.X:0.00},{lo.Y:0.00})->({hi.X:0.00},{hi.Y:0.00})");

    var btr = (BlockTableRecord)tr.GetObject(lay.BlockTableRecordId, OpenMode.ForRead);
    int inside = 0, outside = 0;
    // aggregate group extents by "kind" so the log stays short
    var groups = new SortedDictionary<string, (double minx,double miny,double maxx,double maxy,int n)>(StringComparer.OrdinalIgnoreCase);
    foreach (ObjectId id in btr)
    {
        var ent = tr.GetObject(id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
        if (ent == null) continue;
        string kind;
        if (ent is Viewport v && v.Number != 1) kind = "VIEWPORT";
        else if (ent is Viewport) continue;
        else if (ent is BlockReference br) { var bd=(BlockTableRecord)tr.GetObject(br.BlockTableRecord,OpenMode.ForRead); kind="BLOCK "+bd.Name; }
        else kind = "layer:"+ent.Layer;
        Extents3d ge; try { ge = ent.GeometricExtents; } catch { continue; }
        if (!groups.TryGetValue(kind, out var g)) g = (1e9,1e9,-1e9,-1e9,0);
        g.minx=Math.Min(g.minx,ge.MinPoint.X); g.miny=Math.Min(g.miny,ge.MinPoint.Y);
        g.maxx=Math.Max(g.maxx,ge.MaxPoint.X); g.maxy=Math.Max(g.maxy,ge.MaxPoint.Y); g.n++;
        groups[kind]=g;
    }
    foreach (var kv in groups)
    {
        var g = kv.Value;
        bool ok = g.minx>=lo.X-1 && g.miny>=lo.Y-1 && g.maxx<=hi.X+1 && g.maxy<=hi.Y+1;
        if (ok) inside++; else outside++;
        Log($"   {(ok?"ok  ":"OUT ")}{kv.Key} ({g.n}) : ({g.minx:0.00},{g.miny:0.00})->({g.maxx:0.00},{g.maxy:0.00})");
    }
    Log($"groups inside={inside} outside(>1 unit past paper)={outside}");
    tr.Commit();
}

Result

Status
success
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260613 - 5030 E Lake Pkwy, Stockbridge, GA 30281, USA\SS_Outfall_260612_SHEET.dwg
Message
Executed C3D-PSVERIFY (0 entities touched).
Entities
Duration
316 ms
Civil 3D
25.0.0.0

Log

limits (-0.67,-0.20)->(16.33,10.80)
   ok  BLOCK SS_BLOCK_11X17 (1) : (-0.67,-0.20)->(15.81,10.45)
   OUT BLOCK SS_LEGEND (1) : (12.82,13.18)->(15.53,16.39)
   ok  layer:BLOCK_CLOSURE (32) : (5.89,3.18)->(15.90,4.68)
   OUT layer:BLOCK_NORTH_ARROW (101) : (15.46,13.27)->(15.86,16.33)
   ok  layer:BLOCK_NOTES_FLOOD (2) : (13.05,4.80)->(15.95,7.24)
   ok  layer:SS-BOUNDARY CYAN (1) : (16.06,-0.19)->(16.23,0.10)
   OUT layer:TB1 (2) : (5.43,0.14)->(16.02,16.52)
   ok  VIEWPORT (1) : (-0.93,-0.55)->(16.54,11.19)
groups inside=5 outside(>1 unit past paper)=3

Notes

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

No notes yet.