C3D-0310 · 260610 Tara Blvd: current label positions vs fixture boxes done
READ-ONLY. Rebuilds minimal fixture rectangles and reports every store MText with position, height, rotation, attachment, containing box and off-centre offset. No changes.
C# payload
// READ-ONLY: current state of every store MText, plus the minimal fixture rectangles, plus for
// each tag WHICH box contains it and how far off centre it is. Nothing is modified.
const double H = 0.33;
var ms = (BlockTableRecord)Tx.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(Db), OpenMode.ForRead);
// rebuild minimal rectangles from FIXTURE segments
var hseg = new List<double[]>(); var vseg = new List<double[]>();
foreach (ObjectId id in ms) {
var ln = Tx.GetObject(id, OpenMode.ForRead) as Line;
if (ln == null || !ln.Layer.Equals("FIXTURE", StringComparison.OrdinalIgnoreCase)) continue;
double x1=Math.Round(ln.StartPoint.X,3), y1=Math.Round(ln.StartPoint.Y,3);
double x2=Math.Round(ln.EndPoint.X,3), y2=Math.Round(ln.EndPoint.Y,3);
if (Math.Abs(y1-y2)<0.01) hseg.Add(new double[]{y1,Math.Min(x1,x2),Math.Max(x1,x2)});
else if (Math.Abs(x1-x2)<0.01) vseg.Add(new double[]{x1,Math.Min(y1,y2),Math.Max(y1,y2)});
}
Func<double,double,double,bool> hasH = (y,xa,xb) => { foreach (var s in hseg) if (Math.Abs(s[0]-y)<0.02 && s[1]<=xa+0.02 && s[2]>=xb-0.02) return true; return false; };
Func<double,double,double,bool> hasV = (x,ya,yb) => { foreach (var s in vseg) if (Math.Abs(s[0]-x)<0.02 && s[1]<=ya+0.02 && s[2]>=yb-0.02) return true; return false; };
var xs=new List<double>(); foreach(var s in vseg) if(!xs.Exists(v=>Math.Abs(v-s[0])<0.02)) xs.Add(s[0]);
var ys=new List<double>(); foreach(var s in hseg) if(!ys.Exists(v=>Math.Abs(v-s[0])<0.02)) ys.Add(s[0]);
xs.Sort(); ys.Sort();
var all=new List<double[]>();
for(int i=0;i<xs.Count;i++) for(int j=i+1;j<xs.Count;j++)
for(int k=0;k<ys.Count;k++) for(int l=k+1;l<ys.Count;l++){
double x0=xs[i],x1b=xs[j],y0=ys[k],y1b=ys[l];
if(x1b-x0<0.5||y1b-y0<0.5) continue;
if(!hasH(y0,x0,x1b)||!hasH(y1b,x0,x1b)||!hasV(x0,y0,y1b)||!hasV(x1b,y0,y1b)) continue;
all.Add(new double[]{x0,y0,x1b,y1b});
}
var boxes=new List<double[]>();
foreach(var b in all){
bool bigger=false;
foreach(var o in all){ if(o==b) continue;
if(o[0]>=b[0]-0.01&&o[1]>=b[1]-0.01&&o[2]<=b[2]+0.01&&o[3]<=b[3]+0.01 &&
((o[2]-o[0])*(o[3]-o[1])) < ((b[2]-b[0])*(b[3]-b[1]))-0.01){ bigger=true; break; } }
if(!bigger) boxes.Add(b);
}
Log("minimal fixture boxes: " + boxes.Count);
Log("");
Log("=== EVERY STORE MTEXT, and where it sits ===");
int n=0;
foreach (ObjectId id in ms) {
var mt = Tx.GetObject(id, OpenMode.ForRead) as MText;
if (mt == null) continue;
double px=mt.Location.X, py=mt.Location.Y;
if (px<2261060||px>2261110||py<1391805||py>1391860) continue;
n++;
// which box contains the insertion point
int inBox=-1;
for(int i=0;i<boxes.Count;i++){ var b=boxes[i];
if(px>=b[0]-0.01&&px<=b[2]+0.01&&py>=b[1]-0.01&&py<=b[3]+0.01){ inBox=i; break; } }
string loc;
if(inBox>=0){ var b=boxes[inBox];
double cx=(b[0]+b[2])/2, cy=(b[1]+b[3])/2;
loc=string.Format("box{0} {1:F2}x{2:F2} off-centre dx={3:+0.00;-0.00} dy={4:+0.00;-0.00}",
inBox, b[2]-b[0], b[3]-b[1], px-cx, py-cy);
} else loc="NO BOX";
Log(string.Format("[{0}] ({1:F2},{2:F2}) h={3:F2} rot={4,3:F0} att={5,-12} \"{6}\" -> {7}",
mt.Handle, px, py, mt.TextHeight, mt.Rotation*180/Math.PI, mt.Attachment,
mt.Contents.Replace("\n"," ").Replace(@"\P"," "), loc));
}
Log("");
Log("store MText total: " + n);
Log("");
Log("=== BOXES ===");
for(int i=0;i<boxes.Count;i++){ var b=boxes[i];
Log(string.Format("box{0,-2} ({1:F2},{2:F2})-({3:F2},{4:F2}) {5:F2}x{6:F2} = {7:F2} sf centre ({8:F2},{9:F2})",
i, b[0],b[1],b[2],b[3], b[2]-b[0], b[3]-b[1], (b[2]-b[0])*(b[3]-b[1]), (b[0]+b[2])/2, (b[1]+b[3])/2)); }
Result
Log
minimal fixture boxes: 19 === EVERY STORE MTEXT, and where it sits === [21BCE] (2261084.07,1391831.69) h=0.60 rot= 35 att=BottomLeft "Aisle" -> NO BOX [21BCF] (2261075.66,1391831.61) h=0.60 rot= 35 att=BottomLeft "Aisle" -> NO BOX [21BD0] (2261084.44,1391808.32) h=0.60 rot= 90 att=BottomLeft "locker" -> NO BOX [21BD3] (2261078.60,1391843.08) h=0.60 rot= 0 att=BottomLeft "chips" -> box8 4.00x1.00 off-centre dx=-1.83 dy=+0.38 [21BD4] (2261070.61,1391843.16) h=0.60 rot= 0 att=BottomLeft "chips" -> NO BOX [21BD5] (2261086.55,1391843.20) h=0.60 rot= 0 att=BottomLeft "candy" -> box14 4.00x1.00 off-centre dx=-1.88 dy=+0.51 [21BD6] (2261089.16,1391834.03) h=0.60 rot= 90 att=BottomLeft "drinks" -> box18 1.50x8.50 off-centre dx=-0.02 dy=-3.91 [21BD7] (2261089.46,1391826.96) h=0.60 rot= 90 att=BottomLeft "wine" -> box17 1.50x8.00 off-centre dx=+0.28 dy=-2.73 [21BD8] (2261087.69,1391826.20) h=0.60 rot= 90 att=BottomLeft "snacks" -> box15 1.50x16.50 off-centre dx=+0.02 dy=-7.74 [21BDA] (2261071.97,1391825.95) h=0.60 rot= 90 att=BottomLeft "HOUSEHOLD PRODUCTS" -> box3 1.50x16.50 off-centre dx=+0.29 dy=-7.99 [21BE0] (2261070.16,1391850.94) h=0.60 rot= 0 att=BottomLeft "checkout counters" -> NO BOX [21BE1] (2261071.33,1391808.48) h=0.60 rot= 0 att=BottomLeft "elec room" -> NO BOX [21BE2] (2261087.55,1391810.84) h=0.60 rot= 0 att=BottomLeft "gameroom" -> NO BOX [21BE3] (2261098.62,1391810.58) h=0.60 rot= 0 att=BottomLeft "bathroom" -> NO BOX [21BE4] (2261080.30,1391808.12) h=0.60 rot= 0 att=BottomLeft "exit" -> NO BOX [21BE5] (2261085.48,1391855.65) h=0.60 rot= 0 att=BottomLeft "entrance" -> NO BOX [21BE7] (2261080.08,1391825.96) h=0.33 rot= 90 att=BottomLeft "Dry groceries and baked goods" -> box9 1.50x16.50 off-centre dx=+0.40 dy=-7.98 [21BE8] (2261081.31,1391826.24) h=0.33 rot= 90 att=BottomLeft "Dry groceries and baked goods" -> box11 1.50x16.50 off-centre dx=+0.14 dy=-7.71 [21BE9] (2261078.43,1391842.19) h=0.33 rot= 0 att=BottomLeft "Dry groceries and baked goods" -> box8 4.00x1.00 off-centre dx=-2.00 dy=-0.50 [21BEA] (2261070.43,1391842.19) h=0.33 rot= 0 att=BottomLeft "Dry groceries and baked goods" -> NO BOX [21BEC] (2261089.69,1391834.03) h=0.33 rot= 90 att=BottomLeft "Non-Alcoholic beverages" -> box18 1.50x8.50 off-centre dx=+0.51 dy=-3.91 [21BED] (2261088.22,1391826.20) h=0.33 rot= 90 att=BottomLeft "Dry groceries and baked goods" -> box15 1.50x16.50 off-centre dx=+0.54 dy=-7.74 [21BEF] (2261071.36,1391823.88) h=0.33 rot= 0 att=BottomLeft "Dry groceries and baked goods" -> box4 3.00x2.00 off-centre dx=-1.07 dy=-0.81 [21BF0] (2261078.99,1391824.25) h=0.33 rot= 0 att=BottomLeft "Fresh Fruits & Vegetables" -> box10 3.00x2.00 off-centre dx=-1.44 dy=-0.44 [21BF2] (2261065.13,1391818.59) h=0.33 rot= 90 att=BottomLeft "Frozen Foods" -> NO BOX [21BF4] (2261073.16,1391848.30) h=0.33 rot= 0 att=BottomLeft "Frozen Foods" -> box7 2.50x3.00 off-centre dx=-1.02 dy=+0.61 [21BF6] (2261097.73,1391845.04) h=0.33 rot= 0 att=BottomLeft "Non-Alcoholic beverages" -> NO BOX [21C06] (2261073.43,1391826.18) h=0.33 rot= 90 att=BottomLeft "CANNED FOODS" -> box5 1.50x12.50 off-centre dx=+0.25 dy=-5.77 [21C99] (2261087.09,1391824.11) h=0.33 rot= 0 att=BottomLeft "Dry groceries and baked goods" -> box16 3.00x2.00 off-centre dx=-1.34 dy=-0.59 [21CA1] (2261100.60,1391846.56) h=0.60 rot= 90 att=BottomLeft "drinks" -> NO BOX [21CA9] (2261100.56,1391829.34) h=0.60 rot= 90 att=BottomLeft "beer" -> NO BOX [21CB9] (2261063.73,1391838.39) h=0.33 rot= 0 att=BottomLeft "Frozen Foods" -> NO BOX [21CC1] (2261065.13,1391825.44) h=0.33 rot= 90 att=BottomLeft "dairy" -> NO BOX [21CD6] (2261067.87,1391816.12) h=0.33 rot= 90 att=BottomLeft "dairy" -> box0 4.00x3.00 off-centre dx=+0.44 dy=-0.58 [21CDE] (2261071.21,1391816.14) h=0.33 rot= 90 att=BottomLeft "meats" -> box2 3.00x3.00 off-centre dx=+0.28 dy=-0.55 [21CED] (2261073.81,1391838.48) h=0.33 rot= 90 att=BottomLeft "Dry groceries and baked goods" -> box6 1.50x4.00 off-centre dx=+0.63 dy=-1.71 [21CFB] (2261086.43,1391842.19) h=0.33 rot= 0 att=BottomLeft "Dry groceries and baked goods" -> box14 4.00x1.00 off-centre dx=-2.00 dy=-0.50 [21D30] (2261083.61,1391846.43) h=0.33 rot= 0 att=BottomLeft "Dry groceries and baked goods" -> box12 4.00x3.00 off-centre dx=-1.82 dy=-1.26 [21D40] (2261083.84,1391849.97) h=0.33 rot= 0 att=BottomLeft "Non-Alcoholic beverages" -> box13 4.00x2.00 off-centre dx=-1.59 dy=-0.22 store MText total: 39 === BOXES === box0 (2261065.43,1391815.19)-(2261069.43,1391818.19) 4.00x3.00 = 12.00 sf centre (2261067.43,1391816.69) box1 (2261067.21,1391847.19)-(2261070.21,1391849.19) 3.00x2.00 = 6.00 sf centre (2261068.71,1391848.19) box2 (2261069.43,1391815.19)-(2261072.43,1391818.19) 3.00x3.00 = 9.00 sf centre (2261070.93,1391816.69) box3 (2261070.93,1391825.69)-(2261072.43,1391842.19) 1.50x16.50 = 24.75 sf centre (2261071.68,1391833.94) box4 (2261070.93,1391823.69)-(2261073.93,1391825.69) 3.00x2.00 = 6.00 sf centre (2261072.43,1391824.69) box5 (2261072.43,1391825.69)-(2261073.93,1391838.19) 1.50x12.50 = 18.75 sf centre (2261073.18,1391831.94) box6 (2261072.43,1391838.19)-(2261073.93,1391842.19) 1.50x4.00 = 6.00 sf centre (2261073.18,1391840.19) box7 (2261072.93,1391846.19)-(2261075.43,1391849.19) 2.50x3.00 = 7.50 sf centre (2261074.18,1391847.69) box8 (2261078.43,1391842.19)-(2261082.43,1391843.19) 4.00x1.00 = 4.00 sf centre (2261080.43,1391842.69) box9 (2261078.93,1391825.69)-(2261080.43,1391842.19) 1.50x16.50 = 24.75 sf centre (2261079.68,1391833.94) box10 (2261078.93,1391823.69)-(2261081.93,1391825.69) 3.00x2.00 = 6.00 sf centre (2261080.43,1391824.69) box11 (2261080.43,1391825.69)-(2261081.93,1391842.19) 1.50x16.50 = 24.75 sf centre (2261081.18,1391833.94) box12 (2261083.43,1391846.19)-(2261087.43,1391849.19) 4.00x3.00 = 12.00 sf centre (2261085.43,1391847.69) box13 (2261083.43,1391849.19)-(2261087.43,1391851.19) 4.00x2.00 = 8.00 sf centre (2261085.43,1391850.19) box14 (2261086.43,1391842.19)-(2261090.43,1391843.19) 4.00x1.00 = 4.00 sf centre (2261088.43,1391842.69) box15 (2261086.93,1391825.69)-(2261088.43,1391842.19) 1.50x16.50 = 24.75 sf centre (2261087.68,1391833.94) box16 (2261086.93,1391823.69)-(2261089.93,1391825.69) 3.00x2.00 = 6.00 sf centre (2261088.43,1391824.69) box17 (2261088.43,1391825.69)-(2261089.93,1391833.69) 1.50x8.00 = 12.00 sf centre (2261089.18,1391829.69) box18 (2261088.43,1391833.69)-(2261089.93,1391842.19) 1.50x8.50 = 12.75 sf centre (2261089.18,1391837.94)
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.