C3D-PDFFIT · Fit PDF block to surveyed manholes done
Sets scale 72.9458 / rot 271.329 / insertion so block MH A16 lands on SSMH 1106 and MH A14 on SSMH 1105. Verifies by transforming block symbol centers and measuring error.
C# payload
// Fit the PDF import block so its MH symbols land on the surveyed manhole points.
// Transform solved from 2 controls: block MH A16 -> SSMH 1106, block MH A14 -> SSMH 1105.
// Scale/rotation are whatever makes those fit (72.9458, 271.329 deg) — not a nominal plot scale.
var bt = (BlockTable)Tx.GetObject(Db.BlockTableId, OpenMode.ForRead);
var ms = (BlockTableRecord)Tx.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForRead);
const double SCALE = 72.9458;
const double ROTDEG = 271.329;
var INSERT = new Point3d(73914247.1568, 257513587.8630, 0);
ObjectId tid = ObjectId.Null;
foreach (ObjectId id in ms) {
var o = Tx.GetObject(id, OpenMode.ForRead);
if (o is BlockReference br) {
var d = (BlockTableRecord)Tx.GetObject(br.DynamicBlockTableRecord, OpenMode.ForRead);
if (d.Name.Contains("As Built") || d.Name.Contains("DEV3896")) { tid = id; break; }
}
}
if (tid.IsNull) { Log("PDF block not found."); return; }
var w = (BlockReference)Tx.GetObject(tid, OpenMode.ForWrite);
Log($"before: insert=({w.Position.X:F2},{w.Position.Y:F2}) scale={w.ScaleFactors.X:F4} rot={w.Rotation*180/System.Math.PI:F3}");
w.Position = INSERT;
w.ScaleFactors = new Scale3d(SCALE, SCALE, SCALE);
w.Rotation = ROTDEG * System.Math.PI / 180.0;
var chk = (BlockReference)Tx.GetObject(tid, OpenMode.ForRead);
Log($"after : insert=({chk.Position.X:F2},{chk.Position.Y:F2}) scale={chk.ScaleFactors.X:F4} rot={chk.Rotation*180/System.Math.PI:F3} (verified)");
// verify: transform the block-space MH symbol centers and measure against the surveyed points
var xform = chk.BlockTransform;
var checks = new (string name, Point3d blockPt, Point2d survey)[] {
("A16 -> SSMH 1106", new Point3d(3488946.6984,-1062985.0852,0), new Point2d(2296379.89,1279953.45)),
("A14 -> SSMH 1105", new Point3d(3488946.7660,-1062983.2881,0), new Point2d(2296511.06,1279951.56)),
("A12 (no survey)", new Point3d(3488946.2684,-1062981.2538,0), new Point2d(0,0)),
("A10 (no survey)", new Point3d(3488945.8131,-1062981.2964,0), new Point2d(0,0)),
};
foreach (var (name, bp, sv) in checks) {
var t = bp.TransformBy(xform);
if (sv.X == 0) Log($" {name}: lands at ({t.X:F2},{t.Y:F2})");
else {
double err = new Point2d(t.X, t.Y).GetDistanceTo(sv);
Log($" {name}: lands at ({t.X:F2},{t.Y:F2}) err={err:F3} ft");
}
}
try { var ex = chk.GeometricExtents;
Log($"extents ({ex.MinPoint.X:F0},{ex.MinPoint.Y:F0})-({ex.MaxPoint.X:F0},{ex.MaxPoint.Y:F0}) size {ex.MaxPoint.X-ex.MinPoint.X:F0} x {ex.MaxPoint.Y-ex.MinPoint.Y:F0} ft");
} catch { }
Result
Log
before: insert=(2296379.89,1279953.45) scale=0.6944 rot=87.842 after : insert=(73914247.16,257513587.86) scale=72.9458 rot=271.329 (verified) A16 -> SSMH 1106: lands at (2297607.69,1279622.90) err=1271.518 ft A14 -> SSMH 1105: lands at (2297738.86,1279621.01) err=1271.518 ft A12 (no survey): lands at (2297886.37,1279660.74) A10 (no survey): lands at (2297882.50,1279693.87) extents (2296935,1278999)-(2298724,1280226) size 1790 x 1227 ft
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.