← Inbox

C3DO-0875 · 260714: SO PINS - move view off the notes/vicinity map, bigger masked labels [C3D-SOPINS3] done

SO PINS layout only: viewport view center down so pins clear the paper-space notes and vicinity map; table to 1.0,9.8; this session's SO-PIN-LABELS labels redrawn at 0.15in with background mask.

Script file
C3DO-0875.cs
Target
260714 - 285 Huckaby Rd 22x17.dwg · model space
Author
claude
Approved
yes · auto-auth
Timeout
60s

C# payload

const string LAY="SO-PIN-LABELS", NEWL="SO PINS";
var ld=(DBDictionary)Tx.GetObject(Db.LayoutDictionaryId,OpenMode.ForRead);
var nlay=(Layout)Tx.GetObject(ld.GetAt(NEWL),OpenMode.ForRead);
var nps=(BlockTableRecord)Tx.GetObject(nlay.BlockTableRecordId,OpenMode.ForRead);
foreach(ObjectId id in nps){ var o=Tx.GetObject(id,OpenMode.ForRead);
 if(o is Viewport vp && Math.Abs(1/vp.CustomScale-200)<0.01){ vp.UpgradeOpen(); vp.ViewCenter=new Point2d(2204910,1206338); Log("SO viewport "+vp.Handle+" view center -> 2204910,1206338"); }
 if(o is Autodesk.AutoCAD.DatabaseServices.Table t && t.Layer==LAY){ t.UpgradeOpen(); t.Position=new Point3d(1.0,9.8,0); Log("table "+t.Handle+" -> 1.0,9.8"); } }
// replace this session's SO labels (only entities on SO-PIN-LABELS in model space, made by C3DO-0873)
var bt=(BlockTable)Tx.GetObject(Db.BlockTableId,OpenMode.ForRead);
var ms=(BlockTableRecord)Tx.GetObject(bt[BlockTableRecord.ModelSpace],OpenMode.ForWrite);
int gone=0; foreach(ObjectId id in ms){ var e=Tx.GetObject(id,OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity; if(e!=null&&e.Layer==LAY){ e.UpgradeOpen(); e.Erase(); gone++; } }
Log("old SO labels replaced: "+gone+" entities");
var ts=(TextStyleTable)Tx.GetObject(Db.TextStyleTableId,OpenMode.ForRead); ObjectId sty=ts.Has("SIMPLEX")?ts["SIMPLEX"]:Db.Textstyle;
string[] T={"364/534","406/500","510","520","521","522","523","525","526","527","528","531","538","539","2003"}; double[][] L={new double[]{2206379.572,1207312.932,2206422.547,1207326.280,0},new double[]{2203443.170,1207293.508,2203398.928,1207301.732,1},new double[]{2203438.721,1206809.816,2203393.875,1206806.097,1},new double[]{2203439.294,1206709.997,2203394.719,1206703.829,1},new double[]{2205253.509,1206719.663,2205255.842,1206674.724,0},new double[]{2205255.835,1206798.969,2205259.962,1206754.159,0},new double[]{2206344.787,1206809.190,2206389.376,1206803.125,0},new double[]{2204844.838,1206717.366,2204806.432,1206693.914,1},new double[]{2204842.492,1206967.355,2204797.501,1206968.263,1},new double[]{2205260.785,1206969.705,2205300.591,1206990.692,0},new double[]{2205260.181,1206948.904,2205299.704,1206927.388,0},new double[]{2206348.864,1206959.183,2206387.837,1206981.679,0},new double[]{2205758.849,1207204.963,2205799.505,1207224.252,0},new double[]{2206376.506,1207212.913,2206420.424,1207222.722,0},new double[]{2206368.603,1206955.174,2206412.026,1206943.368,0}}; double H=30;
for(int k=0;k<T.Length;k++){ var a=L[k]; var pin=new Point3d(a[0],a[1],0); var end=new Point3d(a[2],a[3],0); bool left=a[4]>0.5;
 var ln=new Line(pin,end); ln.SetDatabaseDefaults(Db); ln.Layer=LAY; ms.AppendEntity(ln); Tx.AddNewlyCreatedDBObject(ln,true);
 var c=new Circle(pin,Vector3d.ZAxis,6); c.SetDatabaseDefaults(Db); c.Layer=LAY; ms.AppendEntity(c); Tx.AddNewlyCreatedDBObject(c,true);
 var m=new MText(); m.SetDatabaseDefaults(Db); m.Layer=LAY; m.TextStyleId=sty; m.TextHeight=H; m.Contents=T[k];
 m.Attachment=left?AttachmentPoint.MiddleRight:AttachmentPoint.MiddleLeft; m.Location=end+new Vector3d(left?-4:4,0,0);
 m.BackgroundFill=true; m.UseBackgroundColor=true; m.BackgroundScaleFactor=1.2;
 ms.AppendEntity(m); Tx.AddNewlyCreatedDBObject(m,true); }
Log("labels drawn: "+T.Length+" at "+H+"ft (0.15in at 1:200), background mask on");
Ed.Regen();

Result

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

Log

SO viewport 249FA view center -> 2204910,1206338
table 24B66 -> 1.0,9.8
old SO labels replaced: 45 entities
labels drawn: 15 at 30ft (0.15in at 1:200), background mask on

Notes

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

No notes yet.