C3D-PDFFIX · Fix PDF import scale/rotation done
The PDFIMPORT dialog values did not apply (came in 1:1, rot 0, so the sheet is 16x24 ft). Sets scale 50/72 and rotation 87.842 about SSMH 1106, and moves it to its own layer.
C# payload
// Fix the PDFIMPORT block placement: the dialog's scale/rotation didn't apply (came in 1:1, rot 0).
// Set scale = 50/72 ft-per-pt and rotation = 87.842 deg about the insertion point (SSMH 1106 / MH A16),
// then verify by measuring where MH A14 (SSMH 1105) lands. Also move the block off the stale layer.
var bt = (BlockTable)Tx.GetObject(Db.BlockTableId, OpenMode.ForRead);
var ms = (BlockTableRecord)Tx.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForRead);
const double SCALE = 50.0/72.0; // 1" = 50' plot
const double ROTDEG = 87.842;
var A16 = new Point3d(2296379.891, 1279953.449, 0); // SSMH 1106 - insertion/control
var A14 = new Point2d(2296511.06, 1279951.56); // SSMH 1105 - check point
BlockReference target = null; ObjectId tid = ObjectId.Null;
foreach (ObjectId id in ms) {
var o = Tx.GetObject(id, OpenMode.ForRead);
if (o is BlockReference br) {
var def = (BlockTableRecord)Tx.GetObject(br.DynamicBlockTableRecord, OpenMode.ForRead);
if (def.Name.Contains("As Built") || def.Name.Contains("DEV3896")) { target = br; tid = id; break; }
}
}
if (target == null) { Log("PDF import block not found."); return; }
var w = (BlockReference)Tx.GetObject(tid, OpenMode.ForWrite);
Log($"before: insert=({w.Position.X:F3},{w.Position.Y:F3}) scale={w.ScaleFactors.X:F5} rot={w.Rotation*180/System.Math.PI:F3} layer={w.Layer}");
w.Position = A16;
w.ScaleFactors = new Scale3d(SCALE, SCALE, SCALE);
w.Rotation = ROTDEG * System.Math.PI / 180.0;
if (!((LayerTable)Tx.GetObject(Db.LayerTableId, OpenMode.ForRead)).Has("PDF_IMPORT_ASBUILT")) {
var ltw = (LayerTable)Tx.GetObject(Db.LayerTableId, OpenMode.ForWrite);
var rec = new LayerTableRecord { Name = "PDF_IMPORT_ASBUILT",
Color = Autodesk.AutoCAD.Colors.Color.FromColorIndex(Autodesk.AutoCAD.Colors.ColorMethod.ByAci, 8) };
ltw.Add(rec); Tx.AddNewlyCreatedDBObject(rec, true);
}
w.Layer = "PDF_IMPORT_ASBUILT";
var chk = (BlockReference)Tx.GetObject(tid, OpenMode.ForRead);
Log($"after : insert=({chk.Position.X:F3},{chk.Position.Y:F3}) scale={chk.ScaleFactors.X:F5} rot={chk.Rotation*180/System.Math.PI:F3} layer={chk.Layer} (verified)");
try {
var ext = chk.GeometricExtents;
Log($"extents: ({ext.MinPoint.X:F1},{ext.MinPoint.Y:F1}) - ({ext.MaxPoint.X:F1},{ext.MaxPoint.Y:F1})");
Log($"size: {ext.MaxPoint.X-ext.MinPoint.X:F1} x {ext.MaxPoint.Y-ext.MinPoint.Y:F1} ft (expect ~1200 x 1800)");
bool covers = ext.MinPoint.X < A14.X && A14.X < ext.MaxPoint.X && ext.MinPoint.Y < A14.Y && A14.Y < ext.MaxPoint.Y;
Log($"does the import now cover SSMH 1105 / MH A14? {covers}");
} catch { Log("(no extents)"); }
Log("NOTE: verify visually that imported MH A14 sits on SSMH 1105 (2296511.06,1279951.56).");
Result
Log
before: insert=(2296379.891,1279953.449) scale=1.00000 rot=0.000 layer=V-SSWR-MHOL after : insert=(2296379.891,1279953.449) scale=0.69444 rot=87.842 layer=PDF_IMPORT_ASBUILT (verified) extents: (3125264.0,3673312.5) - (3125281.2,3673324.4) size: 17.2 x 11.9 ft (expect ~1200 x 1800) does the import now cover SSMH 1105 / MH A14? False NOTE: verify visually that imported MH A14 sits on SSMH 1105 (2296511.06,1279951.56).
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.