← Inbox

C3D-0313 · 260714 Huckaby: transmission line geometry + linetypes (retry) error

Retry after CS1061 - Database has no Msltscale property. READ-ONLY: transmission/power entities with linetypes, layer settings, loaded linetypes, LTSCALE variables.

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

C# payload

// READ-ONLY: the transmission line entities + every linetype available, to match the PDF's
// ---w---w--- power line symbology.
Log("drawing: " + Db.Filename);
var ms = (BlockTableRecord)Tx.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(Db), OpenMode.ForRead);
Log("=== TRANSMISSION / POWER ENTITIES ===");
foreach (ObjectId id in ms) {
    var ent = Tx.GetObject(id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
    if (ent == null) continue;
    string L = ent.Layer.ToUpper();
    if (L.IndexOf("TRANSMISSION") < 0 && L.IndexOf("POWER") < 0 && L.IndexOf("OHP") < 0 && L.IndexOf("ELEC") < 0) continue;
    var ln = ent as Line;
    var pl = ent as Polyline;
    string geom = "";
    if (ln != null) geom = string.Format("({0:F2},{1:F2})->({2:F2},{3:F2}) len={4:F2}",
        ln.StartPoint.X, ln.StartPoint.Y, ln.EndPoint.X, ln.EndPoint.Y, ln.Length);
    if (pl != null) geom = string.Format("verts={0} len={1:F2} closed={2}", pl.NumberOfVertices, pl.Length, pl.Closed);
    var lt0 = (LinetypeTableRecord)Tx.GetObject(ent.LinetypeId, OpenMode.ForRead);
    Log(string.Format("[{0}] {1,-10} layer={2,-32} ltype={3,-16} ltscale={4:F3} {5}",
        ent.Handle, ent.GetType().Name, ent.Layer, lt0.Name, ent.LinetypeScale, geom));
    if (pl != null) for (int i=0;i<pl.NumberOfVertices;i++){var v=pl.GetPoint2dAt(i);Log(string.Format("     v{0} ({1:F2},{2:F2})",i,v.X,v.Y));}
}
Log("");
Log("=== LAYER SETTINGS for those layers ===");
var lt = (LayerTable)Tx.GetObject(Db.LayerTableId, OpenMode.ForRead);
foreach (ObjectId id in lt) {
    var ltr = (LayerTableRecord)Tx.GetObject(id, OpenMode.ForRead);
    string L = ltr.Name.ToUpper();
    if (L.IndexOf("TRANSMISSION") < 0 && L.IndexOf("POWER") < 0 && L.IndexOf("OHP") < 0 && L.IndexOf("ELEC") < 0) continue;
    var lts = (LinetypeTableRecord)Tx.GetObject(ltr.LinetypeObjectId, OpenMode.ForRead);
    Log(string.Format("{0,-34} ltype={1,-16} color={2} lw={3} frozen={4} off={5}",
        ltr.Name, lts.Name, ltr.Color.ColorIndex, ltr.LineWeight, ltr.IsFrozen, ltr.IsOff));
}
Log("");
Log("=== LINETYPES LOADED ===");
var ltt = (LinetypeTable)Tx.GetObject(Db.LinetypeTableId, OpenMode.ForRead);
foreach (ObjectId id in ltt) {
    var r = (LinetypeTableRecord)Tx.GetObject(id, OpenMode.ForRead);
    Log(string.Format("{0,-22} dashes={1} \"{2}\"", r.Name, r.NumDashes, r.Comments));
}
Log("");
Log("LTSCALE=" + Db.Ltscale + "  CELTSCALE=" + Db.Celtscale + "  PSLTSCALE=" + Db.Psltscale + "  MSLTSCALE=" + Db.Msltscale);

Result

Status
error
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260714 - 285 Huckaby Rd, Brooks, GA 30205, USA\260714 - 285 Huckaby Rd R2.dwg
Message
Compile error: (41,115): error CS1061: 'Database' does not contain a definition for 'Msltscale' and no accessible extension method 'Msltscale' accepting a first argument of type 'Database' could be found (are you missing a using directive or an assembly reference?)
Entities
Duration
819 ms
Civil 3D
25.0.0.0

Notes

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

No notes yet.