C3D-MHOLSYM3 · Place manhole symbols (14) + legend v3 done
Rewritten to use the ambient Tx/ModelSpace globals throughout (root cause of prior error: mixing a locally-opened transaction with the AddMText helper). 13 outfall + 1 bolted + legend.
C# payload
// Place manhole symbols at SSMH points 7000-7013 + a legend block.
// #7013 = SSMH bolted (gray filled, donut) on SEWER_MANHOLE_EXISTING.
// #7000-7012 = Outfall SSMH (blue open circle) on SEWER_MANHOLE.
// Uses the AMBIENT Tx/ModelSpace globals throughout — no separate transactions (that was the bug:
// mixing a locally-opened transaction with the AddMText helper, which uses the plugin's own Tx).
using System;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Colors;
using Autodesk.Civil.ApplicationServices;
using Autodesk.Civil.DatabaseServices;
const double R = 1.0; // circle radius, feet — draft, adjustable
int bolted = 0, outfall = 0;
EnsureLayer("SEWER_MANHOLE", 5);
EnsureLayer("SEWER_MANHOLE_EXISTING", 8);
EnsureLayer("LEGEND", 7);
void PlaceCircle(Point3d center, string layer, short colorIdx)
{
var circ = new Circle(center, Vector3d.ZAxis, R);
circ.Layer = layer;
circ.Color = Color.FromColorIndex(ColorMethod.ByAci, colorIdx);
ModelSpace.AppendEntity(circ);
Tx.AddNewlyCreatedDBObject(circ, true);
}
void PlaceDonut(Point3d center, string layer, short colorIdx)
{
var donut = new Polyline();
donut.AddVertexAt(0, new Point2d(center.X - R, center.Y), 1.0, R, R);
donut.AddVertexAt(1, new Point2d(center.X + R, center.Y), 1.0, R, R);
donut.Closed = true;
donut.Layer = layer;
donut.Color = Color.FromColorIndex(ColorMethod.ByAci, colorIdx);
ModelSpace.AppendEntity(donut);
Tx.AddNewlyCreatedDBObject(donut, true);
}
var cdoc = CivilDocument.GetCivilDocument(Db);
foreach (ObjectId id in cdoc.CogoPoints)
{
var cp = Tx.GetObject(id, OpenMode.ForRead) as CogoPoint;
if (cp == null) continue;
int n = (int)cp.PointNumber;
if (n < 7000 || n > 7013) continue;
var center = new Point3d(cp.Easting, cp.Northing, 0);
if (n == 7013)
{
PlaceCircle(center, "SEWER_MANHOLE_EXISTING", 8);
PlaceDonut(center, "SEWER_MANHOLE_EXISTING", 8);
bolted++;
}
else
{
PlaceCircle(center, "SEWER_MANHOLE", 5);
outfall++;
}
}
Log($"placed manhole symbols: outfall(blue open)={outfall}, bolted(gray filled)={bolted}");
// legend — draft placement near (2297500,1279300)
double ox = 2297500, oy = 1279300, rowH = 8, boxW = 90;
var box = new Polyline();
box.AddVertexAt(0, new Point2d(ox, oy), 0,0,0);
box.AddVertexAt(1, new Point2d(ox+boxW, oy), 0,0,0);
box.AddVertexAt(2, new Point2d(ox+boxW, oy+rowH*5), 0,0,0);
box.AddVertexAt(3, new Point2d(ox, oy+rowH*5), 0,0,0);
box.Closed = true; box.Layer = "LEGEND";
ModelSpace.AppendEntity(box);
Tx.AddNewlyCreatedDBObject(box, true);
AddMText(new Point3d(ox+4, oy+rowH*4.5, 0), "LEGEND", 5, 0, "LEGEND");
PlaceCircle(new Point3d(ox+8, oy+rowH*3.5, 0), "LEGEND", 5);
AddMText(new Point3d(ox+16, oy+rowH*3.5-1.5, 0), "Outfall SSMH (rim / invert)", 3.5, 0, "LEGEND");
PlaceCircle(new Point3d(ox+8, oy+rowH*2.5, 0), "LEGEND", 8);
PlaceDonut(new Point3d(ox+8, oy+rowH*2.5, 0), "LEGEND", 8);
AddMText(new Point3d(ox+16, oy+rowH*2.5-1.5, 0), "SSMH bolted (no invert)", 3.5, 0, "LEGEND");
AddLine(new Point3d(ox+4, oy+rowH*1.5, 0), new Point3d(ox+12, oy+rowH*1.5, 0), "LEGEND");
AddMText(new Point3d(ox+16, oy+rowH*1.5-1.5, 0), "Outfall sewer", 3.5, 0, "LEGEND");
AddLine(new Point3d(ox+4, oy+rowH*0.5, 0), new Point3d(ox+12, oy+rowH*0.5, 0), "LEGEND");
AddMText(new Point3d(ox+16, oy+rowH*0.5-1.5, 0), "40' Sanitary Sewer Easement", 3.5, 0, "LEGEND");
Log("legend placed near (2297500,1279300) — DRAFT position, move as needed.");
Log("DONE.");
Result
Log
placed manhole symbols: outfall(blue open)=13, bolted(gray filled)=1 legend placed near (2297500,1279300) — DRAFT position, move as needed. DONE.
Notes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.