C3D-0630 · R9: move B/L labels onto their setback lines [C3D-0631] done
Fix C3D-0629: the 10 B/L labels (242A6-242AF) were matched to the wrong setback lines (3D distance). Re-match in 2D and move/rotate each label parallel to its line, just off it on the R9 side. Labels are moved, not erased.
C# payload
var ms=(BlockTableRecord)Tx.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(Db),OpenMode.ForRead);
var lines=new List<Line>(); foreach(ObjectId id in ms){ var l=Tx.GetObject(id,OpenMode.ForRead) as Line; if(l!=null&&l.Layer=="SS-BUFFER SETBACK"&&l.Length>40) lines.Add(l); }
var R=new List<object[]>();
R.Add(new object[]{"242A6",2206313.2393,1207052.2888,9.9000,"75' FRONT B/L"});
R.Add(new object[]{"242A7",2206021.5245,1207162.8193,9.9000,"50' SIDE B/L"});
R.Add(new object[]{"242A8",2205752.3734,1207010.7369,9.9000,"50' SIDE B/L"});
R.Add(new object[]{"242A9",2205596.1675,1207050.7318,9.9000,"75' REAR B/L"});
R.Add(new object[]{"242AA",2203503.5350,1206934.5157,9.9000,"75' REAR B/L"});
R.Add(new object[]{"242AB",2204085.7174,1207253.7909,9.9000,"50' SIDE B/L"});
R.Add(new object[]{"242AC",2204085.7174,1206770.4607,9.9000,"50' SIDE B/L"});
R.Add(new object[]{"242AD",2204784.9157,1206806.9265,9.9000,"50' SIDE B/L"});
R.Add(new object[]{"242AE",2205030.1558,1207262.1242,9.9000,"50' SIDE B/L"});
R.Add(new object[]{"242AF",2205030.1558,1207217.4022,9.9000,"50' SIDE B/L"});
foreach(var r in R){ ObjectId mid; Db.TryGetObjectId(new Handle(Convert.ToInt64((string)r[0],16)),out mid); var m=(MText)Tx.GetObject(mid,OpenMode.ForWrite);
string t=(string)r[4]; if(m.Text!=t){ Log((string)r[0]+": text is '"+m.Text+"' not '"+t+"' - skipped"); continue; }
var c=new Point2d((double)r[1],(double)r[2]); double h=(double)r[3];
Line best=null; double bd=1e9; Point2d bp=c;
foreach(var l in lines){ var a=new Point2d(l.StartPoint.X,l.StartPoint.Y); var b=new Point2d(l.EndPoint.X,l.EndPoint.Y); var v=b-a; double tt=Math.Max(0,Math.Min(1,(c-a).DotProduct(v)/v.DotProduct(v))); var p=a+v*tt; double dd=p.GetDistanceTo(c); if(dd<bd){bd=dd;best=l;bp=p;} }
double ang=Math.Atan2(best.EndPoint.Y-best.StartPoint.Y,best.EndPoint.X-best.StartPoint.X); if(ang>Math.PI/2+1e-6) ang-=Math.PI; if(ang<=-Math.PI/2+1e-6) ang+=Math.PI;
var nrm=new Vector2d(-Math.Sin(ang),Math.Cos(ang)); double side=Math.Sign((c-bp).DotProduct(nrm)); if(side==0) side=1;
var loc=bp+nrm*(side*h*1.0);
var old=m.Location; m.Location=new Point3d(loc.X,loc.Y,0); m.Rotation=ang;
Log((string)r[0]+" "+t+": line "+best.Handle+" ("+bd.ToString("F1")+" ft from R9 spot) rot "+(ang*180/Math.PI).ToString("F1")+" moved "+old.DistanceTo(m.Location).ToString("F0")+" ft (verified)");
}
Ed.Regen();
Result
Log
242A6 75' FRONT B/L: line 2346C (16.7 ft from R9 spot) rot 88.2 moved 81 ft (verified) 242A7 50' SIDE B/L: line 23456 (4.5 ft from R9 spot) rot 0.7 moved 200 ft (verified) 242A8 50' SIDE B/L: line 23457 (9.0 ft from R9 spot) rot 0.3 moved 115 ft (verified) 242A9 75' REAR B/L: line 23469 (5.0 ft from R9 spot) rot 25.3 moved 139 ft (verified) 242AA 75' REAR B/L: line 23565 (10.9 ft from R9 spot) rot 90.0 moved 226 ft (verified) 242AB 50' SIDE B/L: line 23564 (5.9 ft from R9 spot) rot 0.4 moved 651 ft (verified) 242AC 50' SIDE B/L: line 23566 (7.0 ft from R9 spot) rot 0.3 moved 750 ft (verified) 242AD 50' SIDE B/L: line 23568 (9.1 ft from R9 spot) rot -89.5 moved 697 ft (verified) 242AE 50' SIDE B/L: line 23564 (8.0 ft from R9 spot) rot 0.4 moved 405 ft (verified) 242AF 50' SIDE B/L: line 23564 (36.7 ft from R9 spot) rot 0.4 moved 406 ft (verified)
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.