C3D-BLDGSHAPE · Building outline ordered by shape done
Reorders the same 10 BLDG points to minimize perimeter^2/area instead of angle score. Ratio 21.1 (building range) vs 82.2 (sliver); 235.9ft perimeter enclosing 2638sf vs 384.6ft enclosing 1798sf.
C# payload
// Building outline, all 10 *BLDG* points, ordered for SHAPE not angle score.
// Prior attempt scored well on 90deg corners but was a zigzag sliver: perim 384.6ft
// enclosing only 1798sf (perimeter^2/area = 82; a square is 16). Five edges shared the same
// bearing = parallel strands, not a perimeter.
// This ordering minimizes perimeter^2/area over all non-self-intersecting rings:
// ratio 21.1, perimeter 235.9ft, area 2638sf, bearings cluster ~52-61 and ~140-146 deg.
// Order 610-613-620-639-640-645-646-701-699-664. No invented vertices.
// Host owns Tx/ModelSpace - no using/Commit here.
int erased = 0;
foreach (ObjectId id in ModelSpace)
{
var e = Tx.GetObject(id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
if (e == null || e.Layer != "SS-V-BLDG-OTLN") continue;
var p = e as Polyline;
if (p == null || p.NumberOfVertices != 10) continue;
var w = (Autodesk.AutoCAD.DatabaseServices.Entity)Tx.GetObject(id, OpenMode.ForWrite);
w.Erase();
erased++;
}
Log($"Erased {erased} prior 10-vertex outline(s).");
var pl = new Polyline();
pl.AddVertexAt(0, new Point2d(2428060.34, 1064523.02), 0, 0, 0);
pl.AddVertexAt(1, new Point2d(2428067.87, 1064517.2), 0, 0, 0);
pl.AddVertexAt(2, new Point2d(2428078.37, 1064498.18), 0, 0, 0);
pl.AddVertexAt(3, new Point2d(2428053.24, 1064460.52), 0, 0, 0);
pl.AddVertexAt(4, new Point2d(2428051.06, 1064462.44), 0, 0, 0);
pl.AddVertexAt(5, new Point2d(2428042.45, 1064446.81), 0, 0, 0);
pl.AddVertexAt(6, new Point2d(2428040.11, 1064448.37), 0, 0, 0);
pl.AddVertexAt(7, new Point2d(2428029.41, 1064434.73), 0, 0, 0);
pl.AddVertexAt(8, new Point2d(2428029.23, 1064434.88), 0, 0, 0);
pl.AddVertexAt(9, new Point2d(2428005.91, 1064452.83), 0, 0, 0);
pl.Closed = true;
pl.Elevation = 419.15;
pl.Layer = "SS-V-BLDG-OTLN";
ModelSpace.AppendEntity(pl);
Tx.AddNewlyCreatedDBObject(pl, true);
Log($"Drew building: {pl.NumberOfVertices} verts, closed={pl.Closed}, len={pl.Length:F1} (was 384.6 sliver).");
Result
Log
Erased 1 prior 10-vertex outline(s). Drew building: 10 verts, closed=True, len=235.9 (was 384.6 sliver).
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.