← Inbox

C3D-0622 · Scale PDF3/4/5 imports to true size (with their circles) done

Scale every model-space object on PDF3_* and PDF4_* layers by 50 (C5.0 / C6.0, 1"=50') and PDF5_* by 20 (C7.0 SWM plan, 1"=20'), each about its circle's centre, and scale the circle with it (4AC89, 4AC8A, 4AC8B). Verify with the graphic scale bar labels (100->200 = 100 ft; 20->40 = 20 ft).

Script file
C3D-0622.cs
Target
260612-C-Store As-Built Storm.dwg · model space
Author
claude
Approved
yes · auto-auth
Timeout
60s

C# payload

var groups=new[]{ new object[]{"PDF3_","4AC89",50.0,"38398","38399",100.0}, new object[]{"PDF4_","4AC8A",50.0,"3FD83","3FD84",100.0}, new object[]{"PDF5_","4AC8B",20.0,"48A6A","48A6B",20.0} };
Func<string,ObjectId> H=(s)=>{ ObjectId i; Db.TryGetObjectId(new Handle(Convert.ToInt64(s,16)),out i); return i; };
var lt=(LayerTable)Tx.GetObject(Db.LayerTableId,OpenMode.ForRead);
var locked=new List<LayerTableRecord>();
foreach(ObjectId id in lt){ var lr=(LayerTableRecord)Tx.GetObject(id,OpenMode.ForRead); if(lr.IsLocked && (lr.Name.StartsWith("PDF3_")||lr.Name.StartsWith("PDF4_")||lr.Name.StartsWith("PDF5_")||lr.Name=="V-NODE-STRM")){ lr.UpgradeOpen(); lr.IsLocked=false; locked.Add(lr); } }
if(locked.Count>0) Log("unlocked "+locked.Count+" layers");
var ms=(BlockTableRecord)Tx.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(Db),OpenMode.ForRead);
foreach(var g in groups){
  string pre=(string)g[0]; var circ=(Circle)Tx.GetObject(H((string)g[1]),OpenMode.ForWrite); double f=(double)g[2];
  var ta=(MText)Tx.GetObject(H((string)g[3]),OpenMode.ForRead); var tb=(MText)Tx.GetObject(H((string)g[4]),OpenMode.ForRead);
  double before=ta.Location.DistanceTo(tb.Location);
  if(Math.Abs(before-(double)g[5])<1.0){ Log(pre+" already at scale (bar "+before.ToString("F2")+") - skipped"); continue; }
  var basePt=circ.Center; var m=Matrix3d.Scaling(f,basePt);
  int n=0, fail=0;
  foreach(ObjectId id in ms){ var en=Tx.GetObject(id,OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity; if(en==null||!en.Layer.StartsWith(pre)) continue;
    try{ en.UpgradeOpen(); en.TransformBy(m); n++; }catch(System.Exception ex){ fail++; if(fail<5) Log("  fail "+en.GetType().Name+" h="+en.Handle+": "+ex.Message); } }
  double r0=circ.Radius; circ.TransformBy(m);
  double after=ta.Location.DistanceTo(tb.Location);
  Log(pre+" x"+f+" about circle centre ("+basePt.X.ToString("F1")+","+basePt.Y.ToString("F1")+"): "+n+" objects scaled, "+fail+" failed; circle r "+r0.ToString("F1")+" -> "+circ.Radius.ToString("F1")+"; scale-bar check "+before.ToString("F2")+" -> "+after.ToString("F2")+" ft (expect "+((double)g[5]).ToString("F0")+")"+(Math.Abs(after-(double)g[5])<1.0?" (verified)":" CHECK"));
}
foreach(var lr in locked) lr.IsLocked=true;
Ed.Regen();

Result

Status
success
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\261004 - 5030 E Lake Pkwy, Stockbridge, GA 30281, USA\260612-C-Store As-Built Storm.dwg
Message
Executed C3D-0622 (0 entities touched).
Entities
—
Duration
2104 ms
Civil 3D
25.0.0.0

Log

PDF3_ x50 about circle centre (2296481.2,1296060.1): 12301 objects scaled, 0 failed; circle r 463.5 -> 23172.9; scale-bar check 2.00 -> 100.00 ft (expect 100) (verified)
PDF4_ x50 about circle centre (2321810.1,1282448.5): 7690 objects scaled, 0 failed; circle r 400.3 -> 20016.8; scale-bar check 2.00 -> 100.00 ft (expect 100) (verified)
PDF5_ x20 about circle centre (2296723.8,1266892.8): 9698 objects scaled, 0 failed; circle r 297.9 -> 5958.6; scale-bar check 1.00 -> 19.90 ft (expect 20) (verified)

Notes

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

No notes yet.