← Inbox

C3D-SEGLBLREAD · Find example plan segment label (read-only) done

Locate the '159 13.9%' style label in plan view + its layer/height/rotation as template.

Script file
C3D-SEGLBLREAD.cs
Target
active document · model space
Author
claude
Approved
yes · claude (read-only)
Timeout
60s

C# payload

// READ-ONLY: find the example segment label in PLAN view (e.g. "159' 13.9%" / "60' DIP / 100' PVC")
// and report its layer, height, rotation, style, position — template for labeling the other segments.
using System;
using Autodesk.AutoCAD.DatabaseServices;

var db = Db;
using (var tr = db.TransactionManager.StartTransaction())
{
    var ms = (BlockTableRecord)tr.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForRead);
    int n = 0;
    foreach (ObjectId id in ms)
    {
        var e = tr.GetObject(id, OpenMode.ForRead);
        string s = null; double x=0,y=0,h=0,rot=0; string layer="", style="";
        if (e is DBText t) { s=t.TextString; x=t.Position.X; y=t.Position.Y; h=t.Height; rot=t.Rotation; layer=t.Layer; style=t.TextStyleName; }
        else if (e is MText m) { s=m.Text; x=m.Location.X; y=m.Location.Y; h=m.TextHeight; rot=m.Rotation; layer=m.Layer; style=""; }
        else continue;
        if (string.IsNullOrWhiteSpace(s)) continue;
        // plan-view window only (model coords of the outfall)
        if (x < 2296700 || x > 2297600 || y < 1279400 || y > 1280300) continue;
        if (!(s.Contains("%") || s.Contains("DIP") || s.Contains("PVC"))) continue;
        Log($"{e.GetType().Name} [{layer}] ({x:0.0},{y:0.0}) h={h:0.00} rot={rot*180/Math.PI:0.0}deg style='{style}' text='{s.Replace("\n"," ")}' handle={((Autodesk.AutoCAD.DatabaseServices.Entity)e).Handle}");
        n++;
    }
    Log($"matches: {n}");
    tr.Commit();
}

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-SEGLBLREAD (0 entities touched).
Entities
Duration
367 ms
Civil 3D
25.0.0.0

Log

matches: 0

Notes

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

No notes yet.