← Inbox

C3D-0013 · Move manhole notes to SEWER_MANHOLE_TEXT [MH-MOVE] done

Moves the 14 MH/RIM/IN/OUT notes and their leaders from SEWER_LINE_TEXT to SEWER_MANHOLE_TEXT. Identified by content so nothing else on the source layer is touched.

Script file
C3D-0013.cs
Target
260612 · model space
Author
claude
Approved
yes · reviewer
Timeout
180s

C# payload

// The manhole invert notes went on SEWER_LINE_TEXT; they belong on SEWER_MANHOLE_TEXT.
// HCWA: text describing a manhole goes on the manhole's own _TEXT layer, not the line's.
// Moves the 14 MText notes and their leaders. Identifies them by content (RIM/IN/OUT) so
// nothing else that may already live on SEWER_LINE_TEXT is disturbed, and moves any leader
// whose endpoint lands on one of those notes.
// Host owns Tx; host regens after commit.
const string FROM = "SEWER_LINE_TEXT", TO = "SEWER_MANHOLE_TEXT";
var ms = (BlockTableRecord)Tx.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(Db), OpenMode.ForWrite);
EnsureLayer(TO, 3);

var notePts = new List<Point3d>();
int moved = 0;

foreach (ObjectId id in ms)
{
    var mt = Tx.GetObject(id, OpenMode.ForRead) as MText;
    if (mt == null || mt.Layer != FROM) continue;
    var c = mt.Contents ?? "";
    if (!(c.Contains("RIM") && c.Contains("OUT"))) continue;
    notePts.Add(mt.Location);
    var w = (MText)Tx.GetObject(id, OpenMode.ForWrite);
    w.Layer = TO;
    moved++;
}
Log("moved " + moved + " note(s) to '" + TO + "'");

int leaders = 0;
foreach (ObjectId id in ms)
{
    var ld = Tx.GetObject(id, OpenMode.ForRead) as Leader;
    if (ld == null || ld.Layer != FROM) continue;
    var end = ld.EndPoint;
    bool mine = false;
    foreach (var p in notePts)
        if (System.Math.Abs(p.X-end.X) < 1.0 && System.Math.Abs(p.Y-end.Y) < 1.0) { mine = true; break; }
    if (!mine) continue;
    var w = (Leader)Tx.GetObject(id, OpenMode.ForWrite);
    w.Layer = TO;
    leaders++;
}
Log("moved " + leaders + " leader(s) to '" + TO + "'");

int onFrom = 0, onTo = 0;
foreach (ObjectId id in ms)
{
    var e = Tx.GetObject(id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
    if (e == null) continue;
    if (e.Layer == FROM) onFrom++;
    if (e.Layer == TO)   onTo++;
}
Log("'" + FROM + "' now holds " + onFrom + " entit(ies); '" + TO + "' holds " + onTo + " (verified)");

Result

Status
success
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260613 - 5030 E Lake Pkwy, Stockbridge, GA 30281, USA\260612 - CSTORE WATER ABS BOUNDARY.dwg
Message
Executed C3D-0013 (0 entities touched).
Entities
Duration
399 ms
Civil 3D
25.0.0.0

Log

moved 14 note(s) to 'SEWER_MANHOLE_TEXT'
moved 13 leader(s) to 'SEWER_MANHOLE_TEXT'
'SEWER_LINE_TEXT' now holds 0 entit(ies); 'SEWER_MANHOLE_TEXT' holds 27 (verified)

Notes

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

No notes yet.