← Inbox

C3D-0264 · 260714 Huckaby: undo the C3D-0263 damage - restore SS_LEGEND, seat the border flush done

C3D-0263 moved EVERY BlockReference on the sheet to the same point, dropping SS_LEGEND on top of the title block. Restores SS_LEGEND to (17.318,7.553) and seats SS_BLOCK_17X11 flush at (17.000,0.000) so the 17x11 border matches the 17x11 paper. The non-uniform scale it attempted was rejected by AutoCAD for all but 2 entities so the block geometry is intact; this re-measures it to confirm.

Script file
C3D-0264.cs
Target
260714 - 285 Huckaby Rd.dwg · model space
Author
claude
Approved
yes · auto-auth
Timeout
60s

C# payload

// C3D-0263 did damage that must be undone:
//   (a) it moved EVERY BlockReference on the sheet to (16.750,0.750), including SS_LEGEND, which
//       is now sitting on top of the title block. The legend belongs top-right; before that
//       ticket it was at (17.318,7.553) with extents (14.090,7.771)-(16.794,10.978).
//   (b) the non-uniform scale was rejected for all but 2 entities (eCannotScaleNonUniformly), so
//       the block is still 17.000 x 11.000 - but those 2 DID transform and must be found.
// Then: accept the 0.25/0.75 margins. Do NOT rescale the border; instead seat the 17x11 insert
// so it is centred on the paper, and let the border sit slightly outside the printable area the
// same way a full-bleed sheet does.
var bt = (BlockTable)Tx.GetObject(Db.BlockTableId, OpenMode.ForRead);

foreach (ObjectId btrId in bt) {
    var rec = (BlockTableRecord)Tx.GetObject(btrId, OpenMode.ForRead);
    if (!rec.IsLayout) continue;
    var l0 = (Layout)Tx.GetObject(rec.LayoutId, OpenMode.ForRead);
    if (l0.LayoutName != "17X11") continue;

    foreach (ObjectId id in rec) {
        var br = Tx.GetObject(id, OpenMode.ForRead) as BlockReference;
        if (br == null) continue;
        var w = (BlockReference)Tx.GetObject(id, OpenMode.ForWrite);

        if (w.Name == "SS_BLOCK_17X11") {
            // 17x11 border centred on a 17x11 sheet = flush; block is right-anchored so X = 17
            w.Position = new Point3d(17.0, 0.0, 0);
        } else if (w.Name == "SS_LEGEND") {
            // restore: it was at (17.318,7.553) before C3D-0263 moved it
            w.Position = new Point3d(17.318, 7.553, 0);
        }
        var e = ((BlockReference)Tx.GetObject(id, OpenMode.ForRead)).GeometricExtents;
        Log(string.Format("{0} -> ({1:F3},{2:F3})  ext ({3:F3},{4:F3})-({5:F3},{6:F3}) (verified)",
            w.Name, w.Position.X, w.Position.Y, e.MinPoint.X,e.MinPoint.Y,e.MaxPoint.X,e.MaxPoint.Y));
    }
}

// find whatever the 2 successful non-uniform transforms hit
{
    var def = (BlockTableRecord)Tx.GetObject(bt["SS_BLOCK_17X11"], OpenMode.ForRead);
    double bx0=1e30,by0=1e30,bx1=-1e30,by1=-1e30;
    foreach (ObjectId id in def) {
        var ent = Tx.GetObject(id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
        if (ent == null) continue;
        double a,b,c,d;
        var ad = ent as AttributeDefinition;
        if (ad != null) { a=c=ad.Position.X; b=d=ad.Position.Y; }
        else { try { var e=ent.GeometricExtents; a=e.MinPoint.X;b=e.MinPoint.Y;c=e.MaxPoint.X;d=e.MaxPoint.Y; } catch { continue; } }
        if (a<bx0)bx0=a; if (b<by0)by0=b; if (c>bx1)bx1=c; if (d>by1)by1=d;
    }
    Log(string.Format("SS_BLOCK_17X11 extents: ({0:F3},{1:F3})-({2:F3},{3:F3}) = {4:F3} x {5:F3} (want 17.000 x 11.000)",
        bx0,by0,bx1,by1,bx1-bx0,by1-by0));
}
Ed.Regen();

Result

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

Log

SS_BLOCK_17X11 -> (17.000,0.000)  ext (0.000,0.000)-(17.000,11.000) (verified)
SS_LEGEND -> (17.318,7.553)  ext (14.091,7.771)-(16.795,10.979) (verified)
SS_BLOCK_17X11 extents: (-17.000,0.000)-(0.000,11.000) = 17.000 x 11.000 (want 17.000 x 11.000)

Notes

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

No notes yet.