C3DO-0753 · 261101: legend into the 11X17 layout + missing items [C3D-LEGEND] done
Explode the SS_LEGEND insert (1FDBA) on 11X17 into loose paper-space items (block definition kept). Add abbreviations IPS, OTP, CTP, DB, PB, FF after PP and slide the symbol rows down to stay on their words. Append POWER POLE and GAS METER symbols (the point styles' own blocks) and sample lines for BOUNDARY, ADJOINER, CENTERLINE, STORM SEWER EASEMENT, BUFFER / SETBACK on their own layers (LT scale 0.5).
C# payload
Func<string,ObjectId> oid=hs=>{ ObjectId id; Db.TryGetObjectId(new Handle(Convert.ToInt64(hs,16)),out id); return id; };
var abbr=new[]{"IPS IRON PIN SET","OTP OPEN TOP PIPE","CTP CRIMP TOP PIPE","DB DEED BOOK","PB PLAT BOOK","FF FINISHED FLOOR"};
var icons=new List<Tuple<string,string,string,double>>();
icons.Add(Tuple.Create("POWER POLE","blk","Utility Pole",0.7));
icons.Add(Tuple.Create("GAS METER","blk","Gas Valve",0.69812871778162));
icons.Add(Tuple.Create("BOUNDARY LINE","line","C-PROP-LINE",0.0));
icons.Add(Tuple.Create("ADJOINER LINE","line","V-GIS-PROP-ADJ",0.0));
icons.Add(Tuple.Create("CENTERLINE","line","SS-V-ROAD-CNTR",0.0));
icons.Add(Tuple.Create("STORM SEWER EASEMENT","line","X-ESMT-STRM",0.0));
icons.Add(Tuple.Create("BUFFER / SETBACK LINE","line","SS-BUFFER SETBACK",0.0));
Func<MText,Dictionary<string,double>> lines=m=>{ var d=new Dictionary<string,double>(); var c=new DBObjectCollection(); m.Explode(c); foreach(Autodesk.AutoCAD.DatabaseServices.DBObject o in c){ var t=o as DBText; if(t!=null&&!d.ContainsKey(t.TextString.Trim())) d[t.TextString.Trim()]=t.Position.Y; o.Dispose(); } return d; };
var rid=oid("1FDBA");
if(rid.IsNull||rid.IsErased){ Log("STOP - legend insert 1FDBA not found (already exploded?)"); return; }
var br=(BlockReference)Tx.GetObject(rid,OpenMode.ForRead);
if(br.Name!="SS_LEGEND"){ Log("STOP - 1FDBA is "+br.Name); return; }
var sp=(BlockTableRecord)Tx.GetObject(br.OwnerId,OpenMode.ForWrite);
var lay=(Layout)Tx.GetObject(sp.LayoutId,OpenMode.ForRead);
if(lay.LayoutName!="11X17"){ Log("STOP - 1FDBA is on "+lay.LayoutName); return; }
var coll=new DBObjectCollection(); br.Explode(coll);
MText mt=null; var icon=new List<Autodesk.AutoCAD.DatabaseServices.Entity>(); int n=0;
foreach(Autodesk.AutoCAD.DatabaseServices.DBObject o in coll){ var e=(Autodesk.AutoCAD.DatabaseServices.Entity)o; sp.AppendEntity(e); Tx.AddNewlyCreatedDBObject(e,true); n++;
if(e is MText m && m.Contents.Contains("IRON PIN FOUND")) mt=m; else if(e is DBText t && t.TextString=="LEGEND"){} else icon.Add(e); }
br.UpgradeOpen(); br.Erase();
Log("exploded 1FDBA into "+n+" items on 11X17 ("+icon.Count+" icon pieces); insert removed, SS_LEGEND definition kept");
if(mt==null){ Log("STOP - legend text not found after explode"); throw new Exception("no mtext - rolled back"); }
var before=lines(mt); double oldDI=before["DROP INLET"];
string c0=mt.Contents; int at=c0.IndexOf(@"\P DROP INLET");
if(at<0) throw new Exception("DROP INLET line not found - rolled back");
string add=""; foreach(var a in abbr) add+=@"\P"+a;
string tail=""; foreach(var ic in icons) tail+=@"\P "+ic.Item1;
mt.Contents=c0.Substring(0,at)+add+c0.Substring(at)+tail;
var after=lines(mt); double dy=after["DROP INLET"]-oldDI;
foreach(var e in icon) e.TransformBy(Matrix3d.Displacement(new Vector3d(0,dy,0)));
Log("added "+abbr.Length+" abbreviation lines after PP; moved the "+icon.Count+" icon pieces "+dy.ToString("F4")+" to stay on their words");
double off=0.045, xc=-3.122087613577552+br.Position.X, x0=-3.2270350828913195+br.Position.X, x1=-2.95291828733221+br.Position.X;
var bt=(BlockTable)Tx.GetObject(Db.BlockTableId,OpenMode.ForRead); var lt=(LayerTable)Tx.GetObject(Db.LayerTableId,OpenMode.ForRead);
foreach(var ic in icons){ double y=after[ic.Item1]+off;
if(ic.Item2=="blk"){ if(!bt.Has(ic.Item3)){ Log(" skip "+ic.Item1+" - no block "+ic.Item3); continue; }
var r=new BlockReference(new Point3d(xc,y,0),bt[ic.Item3]); r.SetDatabaseDefaults(Db); r.Layer="BLOCK_LEGEND"; r.ScaleFactors=new Scale3d(ic.Item4); sp.AppendEntity(r); Tx.AddNewlyCreatedDBObject(r,true);
Log(" "+ic.Item1+": "+ic.Item3+" symbol "+r.Handle+" at y "+y.ToString("F4")); }
else { if(!lt.Has(ic.Item3)){ Log(" skip "+ic.Item1+" - no layer "+ic.Item3); continue; }
var l=new Line(new Point3d(x0,y,0),new Point3d(x1,y,0)); l.SetDatabaseDefaults(Db); l.Layer=ic.Item3; l.LinetypeScale=0.5; sp.AppendEntity(l); Tx.AddNewlyCreatedDBObject(l,true);
Log(" "+ic.Item1+": sample line "+l.Handle+" on "+ic.Item3+" at y "+y.ToString("F4")); } }
Log("legend text now "+after.Count+" lines, "+mt.Handle+" (verified)");
Ed.Regen();
Result
Log
exploded 1FDBA into 33 items on 11X17 (31 icon pieces); insert removed, SS_LEGEND definition kept added 6 abbreviation lines after PP; moved the 31 icon pieces -0.9521 to stay on their words POWER POLE: Utility Pole symbol 2193D at y 2.6156 GAS METER: Gas Valve symbol 2193E at y 2.4569 BOUNDARY LINE: sample line 2193F on C-PROP-LINE at y 2.2982 ADJOINER LINE: sample line 21940 on V-GIS-PROP-ADJ at y 2.1395 CENTERLINE: sample line 21941 on SS-V-ROAD-CNTR at y 1.9809 STORM SEWER EASEMENT: sample line 21942 on X-ESMT-STRM at y 1.8222 BUFFER / SETBACK LINE: sample line 21943 on SS-BUFFER SETBACK at y 1.6444 legend text now 32 lines, 2191D (verified)
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.