← Inbox

C3D-0318 · 260714 Huckaby R2: power centrelines to ----W----W---- like the plat done

Creates a POWER_LINE linetype built the same way as this drawings own GAS_LINE/Sewer/FENCELINEX text-glyph patterns (3 dashes, patLen 0.95, middle element carries the letter W). Assigns it to SS-V-POWER-CL only - the 4 centrelines that are currently Continuous - and sets them ByLayer at LinetypeScale 20 so the ~19 ft repeat reads at plot scale with LTSCALE=1. SS-V-POWER-EASEMENT keeps its DASHED look, which already matches the plats easement boundary. Verifies the linetype dashes, layer assignment and each entity with an estimated glyph count.

Script file
C3D-0318.cs
Target
260714 - 285 Huckaby Rd R2.dwg · model space
Author
claude
Approved
yes · auto-auth
Timeout
60s

C# payload

// Make the power CENTERLINES read like the recorded plat (Book 32 Page 175): ----W----W----W----
//
// VERIFIED against THIS drawing (C3D-0317), not an earlier file:
//   layer SS-V-POWER-CL        Continuous, colour 1, 4 lines  <- the ones to change
//   layer SS-V-POWER-EASEMENT  DASHED, ltscale 0.33, 8 lines  <- left alone, that is the
//                              easement boundary and it already reads as dashed like the plat
//   LTSCALE=1, so the pattern length is in real drawing units (feet here).
//
// The drawing already carries three text-glyph linetypes made this way - GAS_LINE, Sewer and
// FENCELINEX, all patLen 0.95 with 3 dashes. POWER_LINE copies that construction with a W, then
// gets a LinetypeScale that suits the 1500 ft runs.
const string LTNAME = "POWER_LINE";
const string LAYER  = "SS-V-POWER-CL";

Log("drawing: " + Db.Filename);

var lt = (LayerTable)Tx.GetObject(Db.LayerTableId, OpenMode.ForRead);
if (!lt.Has(LAYER)) { Log("layer " + LAYER + " not in this drawing - stopping."); return; }

var tst = (TextStyleTable)Tx.GetObject(Db.TextStyleTableId, OpenMode.ForRead);
ObjectId styleId = tst.Has("Standard") ? tst["Standard"] : Db.Textstyle;

// ---- build the linetype the same shape as the drawing's own GAS_LINE
var ltt = (LinetypeTable)Tx.GetObject(Db.LinetypeTableId, OpenMode.ForWrite);
ObjectId ltId;
if (ltt.Has(LTNAME)) {
    ltId = ltt[LTNAME];
    Log("linetype " + LTNAME + " already present - reusing");
} else {
    var rec = new LinetypeTableRecord();
    rec.Name = LTNAME;
    rec.Comments = "Power line ----W----W----W----W----W---";
    rec.PatternLength = 0.95;
    rec.NumDashes = 3;
    rec.SetDashLengthAt(0, 0.5);            // the drawn segment
    rec.SetDashLengthAt(1, -0.2);           // gap holding the glyph
    rec.SetShapeStyleAt(1, styleId);
    rec.SetShapeNumberAt(1, 0);
    rec.SetTextAt(1, "W");
    rec.SetShapeScaleAt(1, 0.2);
    rec.SetShapeOffsetAt(1, new Vector2d(-0.1, -0.05));
    rec.SetShapeRotationAt(1, 0.0);
    rec.SetShapeIsUcsOrientedAt(1, false);
    rec.SetDashLengthAt(2, -0.25);          // trailing gap
    ltId = ltt.Add(rec);
    Tx.AddNewlyCreatedDBObject(rec, true);
    Log("created linetype " + LTNAME);
}
{
    var r = (LinetypeTableRecord)Tx.GetObject(ltId, OpenMode.ForRead);
    Log(string.Format("  {0}: dashes={1} patLen={2:F3}", r.Name, r.NumDashes, r.PatternLength));
    for (int i = 0; i < r.NumDashes; i++) {
        string t = ""; try { t = r.TextAt(i); } catch { }
        Log(string.Format("     dash{0} len={1,6:F3} text=\"{2}\"", i, r.DashLengthAt(i), t));
    }
}

// ---- assign to the centreline layer only
var ltr = (LayerTableRecord)Tx.GetObject(lt[LAYER], OpenMode.ForWrite);
ltr.LinetypeObjectId = ltId;
{
    var back = (LayerTableRecord)Tx.GetObject(lt[LAYER], OpenMode.ForRead);
    var used = (LinetypeTableRecord)Tx.GetObject(back.LinetypeObjectId, OpenMode.ForRead);
    Log("layer " + back.Name + " linetype -> " + used.Name + " (verified)");
}

// ---- the runs are 350-1600 ft with LTSCALE=1, so scale the pattern up to read on the sheet.
// At 1"=100' plotting, a ~20 ft repeat looks like the plat: 0.95 * 20 = 19 ft per W.
const double LTS = 20.0;
var ms = (BlockTableRecord)Tx.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(Db), OpenMode.ForWrite);
int n = 0;
foreach (ObjectId id in ms) {
    var probe = Tx.GetObject(id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
    if (probe == null || !probe.Layer.Equals(LAYER, StringComparison.OrdinalIgnoreCase)) continue;
    var w = (Autodesk.AutoCAD.DatabaseServices.Entity)Tx.GetObject(id, OpenMode.ForWrite);
    w.LinetypeId = Db.ByLayerLinetype;
    w.LinetypeScale = LTS;
    n++;
    var back = (Autodesk.AutoCAD.DatabaseServices.Entity)Tx.GetObject(id, OpenMode.ForRead);
    var bl = (LinetypeTableRecord)Tx.GetObject(back.LinetypeId, OpenMode.ForRead);
    var line = back as Line;
    Log(string.Format("  [{0}] ltype={1} ltscale={2:F2} len={3:F1} -> ~{4:F0} W glyphs (verified)",
        back.Handle, bl.Name, back.LinetypeScale,
        line != null ? line.Length : 0.0,
        line != null ? line.Length / (0.95 * LTS) : 0.0));
}
Log("");
Log(string.Format("{0} applied to {1} via layer {2}; SS-V-POWER-EASEMENT left on DASHED as-is",
    LTNAME, n + " centrelines", LAYER));
Ed.Regen();

Result

Status
success
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260714 - 285 Huckaby Rd, Brooks, GA 30205, USA\260714 - 285 Huckaby Rd R2.dwg
Message
Executed C3D-0318 (0 entities touched).
Entities
Duration
697 ms
Civil 3D
25.0.0.0

Log

drawing: C:\Users\sanja\OneDrive\_SurveyDisco\260714 - 285 Huckaby Rd, Brooks, GA 30205, USA\260714 - 285 Huckaby Rd R2.dwg
created linetype POWER_LINE
  POWER_LINE: dashes=3 patLen=0.950
     dash0 len= 0.500 text=""
     dash1 len=-0.200 text="W"
     dash2 len=-0.250 text=""
layer SS-V-POWER-CL linetype -> POWER_LINE (verified)
  [20C9D] ltype=ByLayer ltscale=20.00 len=893.0 -> ~47 W glyphs (verified)
  [20C9E] ltype=ByLayer ltscale=20.00 len=364.6 -> ~19 W glyphs (verified)
  [20CA9] ltype=ByLayer ltscale=20.00 len=1514.6 -> ~80 W glyphs (verified)
  [20CB1] ltype=ByLayer ltscale=20.00 len=1569.6 -> ~83 W glyphs (verified)

POWER_LINE applied to 4 centrelines via layer SS-V-POWER-CL; SS-V-POWER-EASEMENT left on DASHED as-is

Notes

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

No notes yet.