C3DO-0859 · 261103: N/F labels inside their lots [C3D-RL1103-4F] done
Moves each N/F label inside its adjoining lot between that lot's side lines (22146 / 22140 / 2208D) and checks containment; Southern Eagle reads up the strip east of the subject.
C# payload
string F(double v)=>v.ToString("0.###");
ObjectId H(string h)=>Db.GetObjectId(false,new Handle(Convert.ToInt64(h,16)),0);
ObjectId Lyr(string name,short c){ var lt=(LayerTable)Tx.GetObject(Db.LayerTableId,OpenMode.ForRead); if(lt.Has(name)) return lt[name]; lt.UpgradeOpen(); var r=new LayerTableRecord{Name=name,Color=Autodesk.AutoCAD.Colors.Color.FromColorIndex(Autodesk.AutoCAD.Colors.ColorMethod.ByAci,c)}; var id=lt.Add(r); Tx.AddNewlyCreatedDBObject(r,true); Log("layer created "+name); return id; }
ObjectId Put(BlockTableRecord btr, Autodesk.AutoCAD.DatabaseServices.Entity e, string layer){ e.SetDatabaseDefaults(Db); e.Layer=layer; var id=btr.AppendEntity(e); Tx.AddNewlyCreatedDBObject(e,true); return id; }
var LM=LayoutManager.Current;
BlockTableRecord PS(string name){ var l=(Layout)Tx.GetObject(LM.GetLayoutId(name),OpenMode.ForRead); return (BlockTableRecord)Tx.GetObject(l.BlockTableRecordId,OpenMode.ForWrite); }
var BT=(BlockTable)Tx.GetObject(Db.BlockTableId,OpenMode.ForRead);
var MS=(BlockTableRecord)Tx.GetObject(BT[BlockTableRecord.ModelSpace],OpenMode.ForWrite);
bool HasText(BlockTableRecord btr,string contains){ foreach(ObjectId id in btr){ var o=Tx.GetObject(id,OpenMode.ForRead); if(o is MText m && m.Contents.Contains(contains)) return true; if(o is DBText t && t.TextString.Contains(contains)) return true; } return false; }
// 261103: each N/F label INSIDE its adjoiner's lot, between that lot's side lines (user: "keep them inside the adjoiner lines").
// Lot 1 U3: west of side line 22146. Lot 23 U2: between 22146 and 22140. Lot 24 U2: between 22140 and 2208D.
// Southern Eagle: east of the subject east line, north of Lot 24 (narrow strip to the sheet edge -> reads up the line).
double X(string h,double y){ var l=(Line)Tx.GetObject(H(h),OpenMode.ForRead); var a=l.StartPoint; var b=l.EndPoint; return a.X+(b.X-a.X)*(y-a.Y)/(b.Y-a.Y); }
var J=new (string h,double x,double y,double rotDeg,double th)[]{
("22249",2271610,1283388,0.381,4.0),
("22247",2271812,1283400,0.381,4.0),
("22248",2271987,1283428,20.776,4.0),
("2224A",2271963,1283560,86.142,3.5),
};
foreach(var j in J){ var m=(MText)Tx.GetObject(H(j.h),OpenMode.ForWrite); var o=m.Location;
m.Location=new Point3d(j.x,j.y,0); m.Rotation=j.rotDeg*Math.PI/180; m.TextHeight=j.th;
var x=m.GeometricExtents; Log(j.h+" "+F(o.X)+","+F(o.Y)+" -> "+F(j.x)+","+F(j.y)+" box x "+F(x.MinPoint.X)+"-"+F(x.MaxPoint.X)+" y "+F(x.MinPoint.Y)+"-"+F(x.MaxPoint.Y)); }
// containment check against the side lines at the box's top and bottom
Func<string,Extents3d> B=h=>((MText)Tx.GetObject(H(h),OpenMode.ForRead)).GeometricExtents;
var b1=B("22249"); Log("Lot 1: right edge "+F(b1.MaxPoint.X)+" < 22146 "+F(Math.Min(X("22146",b1.MinPoint.Y),X("22146",b1.MaxPoint.Y)))+(b1.MaxPoint.X<Math.Min(X("22146",b1.MinPoint.Y),X("22146",b1.MaxPoint.Y))?" OK":" OUT"));
var b2=B("22247"); double l2=Math.Max(X("22146",b2.MinPoint.Y),X("22146",b2.MaxPoint.Y)), r2=Math.Min(X("22140",b2.MinPoint.Y),X("22140",b2.MaxPoint.Y)); Log("Lot 23: "+F(l2)+" < "+F(b2.MinPoint.X)+" .. "+F(b2.MaxPoint.X)+" < "+F(r2)+(b2.MinPoint.X>l2&&b2.MaxPoint.X<r2?" OK":" OUT"));
var b3=B("22248"); double l3=Math.Max(X("22140",b3.MinPoint.Y),X("22140",b3.MaxPoint.Y)), r3=Math.Min(X("2208D",b3.MinPoint.Y),X("2208D",b3.MaxPoint.Y)); Log("Lot 24: "+F(l3)+" < "+F(b3.MinPoint.X)+" .. "+F(b3.MaxPoint.X)+" < "+F(r3)+(b3.MinPoint.X>l3&&b3.MaxPoint.X<r3?" OK":" OUT"));
var b4=B("2224A"); Log("Southern Eagle: x "+F(b4.MinPoint.X)+" > east line 2271934.8, y "+F(b4.MinPoint.Y)+" > Lot 24 top 1283513"+(b4.MinPoint.X>2271935&&b4.MinPoint.Y>1283513?" OK":" OUT"));
Ed.Regen();
Result
Log
22249 2271699.059,1283390.526 -> 2271610,1283388 box x 2271562.271-2271657.729 y 1283370.922-1283405.078 22247 2271843.533,1283419.653 -> 2271812,1283400 box x 2271768.556-2271855.444 y 1283382.95-1283417.05 22248 2271932.381,1283439.094 -> 2271987,1283428 box x 2271942.32-2272031.68 y 1283397.633-1283458.367 2224A 2272001.679,1283551.39 -> 2271963,1283560 box x 2271945.111-2271980.889 y 1283520.556-1283599.444 Lot 1: right edge 2271657.729 < 22146 2271705.956 OK Lot 23: 2271708.129 < 2271768.556 .. 2271855.444 < 2271923.705 OK Lot 24: 2271932.879 < 2271942.32 .. 2272031.68 < 2272042.339 OK Southern Eagle: x 2271945.111 > east line 2271934.8, y 1283520.556 > Lot 24 top 1283513 OK
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.