← Inbox

C3D-MHOL5FT · Replace manhole symbols with 5ft radius done

Erase the existing 10ft SEWER_MANHOLE/SEWER_MANHOLE_EXISTING circles+donuts, redraw all 14 (13 outfall + 1 bolted) at 5ft radius. Legend untouched.

Script file
C3D-MHOL5FT.cs
Target
SS_Outfall_260612_SHEET.dwg · model space
Author
claude
Approved
yes · auto-auth
Timeout
60s

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 = 5.0; // circle radius, feet — reduced from 10 per user
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);
}

// remove the existing 10ft-radius manhole symbols before redrawing at 5ft (avoid duplicates)
int erased = 0;
foreach (ObjectId id in ModelSpace)
{
    var e = Tx.GetObject(id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
    if (e == null) continue;
    if (!string.Equals(e.Layer, "SEWER_MANHOLE", StringComparison.OrdinalIgnoreCase)
     && !string.Equals(e.Layer, "SEWER_MANHOLE_EXISTING", StringComparison.OrdinalIgnoreCase)) continue;
    if (!(e is Circle) && !(e is Polyline)) continue;
    var w = (Autodesk.AutoCAD.DatabaseServices.Entity)Tx.GetObject(id, OpenMode.ForWrite);
    w.Erase();
    erased++;
}
Log($"erased existing manhole symbols (10ft version): {erased}");

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}");
Log("DONE. Legend not touched — user is fixing it directly.");

Result

Status
success
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260613 - 5030 E Lake Pkwy, Stockbridge, GA 30281, USA\SS_Outfall_260612_SHEET.dwg
Message
Executed C3D-MHOL5FT (0 entities touched).
Entities
Duration
398 ms
Civil 3D
25.0.0.0

Log

erased existing manhole symbols (10ft version): 27
placed manhole symbols: outfall(blue open)=13, bolted(gray filled)=1
DONE. Legend not touched — user is fixing it directly.

Notes

What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.

No notes yet.