C3D-PKFILL · Connect parking stripes from points done
Pair surveyed STRIPE points into stripe lines; skip existing
C# payload
// Connect surveyed parking-stripe points into stripes: pair each STRIPE point with its nearest
// partner ~15-25' away along the stripe axis (ESE, from the user's stripes). Skip existing lines.
var bt = (BlockTable)Tx.GetObject(Db.BlockTableId, OpenMode.ForRead);
var ms = (BlockTableRecord)Tx.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
EnsureLayer("SS-V-ROAD-CURB", 1);
var cd = CivilDoc; var cps = cd.CogoPoints;
var pts = new List<(uint num, Point2d p)>();
foreach (ObjectId id in cps) { var cp = (Autodesk.Civil.DatabaseServices.CogoPoint)Tx.GetObject(id, OpenMode.ForRead); if ((cp.RawDescription ?? "").ToUpperInvariant().Contains("STRIPE")) pts.Add((cp.PointNumber, new Point2d(cp.Easting, cp.Northing))); }
Log($"STRIPE points: {pts.Count}");
// stripe axis from user's #365->#364 (19.20,-5.16); perp filters out along-row neighbors
double axL = System.Math.Sqrt(19.20 * 19.20 + 5.16 * 5.16);
double pxX = 5.16 / axL, pxY = 19.20 / axL; // perpendicular to the axis
var existing = new List<(Point2d a, Point2d b)>();
foreach (ObjectId id in ms) { if (Tx.GetObject(id, OpenMode.ForRead) is Line ln) existing.Add((new Point2d(ln.StartPoint.X, ln.StartPoint.Y), new Point2d(ln.EndPoint.X, ln.EndPoint.Y))); }
bool Exists(Point2d a, Point2d b) { foreach (var e in existing) if ((e.a.GetDistanceTo(a) < 0.2 && e.b.GetDistanceTo(b) < 0.2) || (e.a.GetDistanceTo(b) < 0.2 && e.b.GetDistanceTo(a) < 0.2)) return true; return false; }
var drawn = new HashSet<string>();
int n = 0, skip = 0;
for (int i = 0; i < pts.Count; i++) {
var P = pts[i]; int bestJ = -1; double bd = 1e9;
for (int j = 0; j < pts.Count; j++) {
if (i == j) continue; double d = P.p.GetDistanceTo(pts[j].p); if (d < 15 || d > 25) continue;
double dx = (pts[j].p.X - P.p.X) / d, dy = (pts[j].p.Y - P.p.Y) / d;
if (System.Math.Abs(dx * pxX + dy * pxY) > 0.34) continue; // must run along the stripe axis
if (d < bd) { bd = d; bestJ = j; }
}
if (bestJ < 0) continue;
uint a = System.Math.Min(P.num, pts[bestJ].num), b = System.Math.Max(P.num, pts[bestJ].num);
string key = a + "-" + b; if (drawn.Contains(key)) continue; drawn.Add(key);
if (Exists(P.p, pts[bestJ].p)) { skip++; continue; }
var l = new Line(new Point3d(P.p.X, P.p.Y, 0), new Point3d(pts[bestJ].p.X, pts[bestJ].p.Y, 0)); l.Layer = "SS-V-ROAD-CURB";
ms.AppendEntity(l); Tx.AddNewlyCreatedDBObject(l, true); n++;
}
Log($"drew {n} parking stripes ({skip} already existed)");
Result
Log
STRIPE points: 113 drew 45 parking stripes (5 already existed)
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.