← Inbox

C3D-260619-HEROVIS · Why are HERO/TRACT layers invisible on 22X17 C done

Read-only: layer on/frozen/plot state, per-viewport frozen layers on the 22X17 C sheet, and whether entities exist on the HERO/TRACT layers.

Script file
C3D-260619-HEROVIS.cs
Target
260619 · paper space
Author
claude
Approved
yes · auto-auth
Timeout
60s

C# payload

// READ-ONLY: why SS-HERO-TRACT A/B ANNO layers are on but invisible on the 22X17 C sheet.
// Checks: layer state (off/frozen/plottable), per-viewport freeze (VP FREEZE), and whether any
// entities on those layers actually exist / where they are.
const string LAYOUT = "22X17 C";

var lt = (LayerTable)Tx.GetObject(Db.LayerTableId, OpenMode.ForRead);
var hero = new List<ObjectId>();
Log("--- layers matching HERO/TRACT ---");
foreach (ObjectId id in lt)
{
    var ltr = (LayerTableRecord)Tx.GetObject(id, OpenMode.ForRead);
    var n = ltr.Name.ToUpper();
    if (!(n.Contains("HERO") || n.Contains("TRACT"))) continue;
    hero.Add(id);
    Log("  '" + ltr.Name + "' off=" + ltr.IsOff + " frozen=" + ltr.IsFrozen + " locked=" + ltr.IsLocked +
        " plot=" + ltr.IsPlottable + " color=" + ltr.Color.ColorIndex + " vpdflt-frozen=" + ltr.ViewportVisibilityDefault);
}
if (hero.Count == 0) Log("  (none found)");

// per-viewport frozen layers
var layDict = (DBDictionary)Tx.GetObject(Db.LayoutDictionaryId, OpenMode.ForRead);
var layout  = (Layout)Tx.GetObject(layDict.GetAt(LAYOUT), OpenMode.ForRead);
var ps      = (BlockTableRecord)Tx.GetObject(layout.BlockTableRecordId, OpenMode.ForRead);
Log("--- viewports on '" + LAYOUT + "' ---");
foreach (ObjectId id in ps)
{
    var vp = Tx.GetObject(id, OpenMode.ForRead) as Viewport;
    if (vp == null) continue;
    Log("  Viewport h=" + vp.Handle + " num=" + vp.Number + " on=" + vp.On +
        " centre(" + vp.CenterPoint.X.ToString("F2") + "," + vp.CenterPoint.Y.ToString("F2") + ")" +
        " w=" + vp.Width.ToString("F2") + " h=" + vp.Height.ToString("F2") +
        " scale=1:" + (vp.CustomScale > 0 ? (1.0/vp.CustomScale).ToString("F1") : "?"));
    var frozen = vp.GetFrozenLayers();
    if (frozen == null || frozen.Count == 0) { Log("      no per-viewport frozen layers"); continue; }
    var names = new List<string>();
    foreach (ObjectId f in frozen)
    {
        var ltr = Tx.GetObject(f, OpenMode.ForRead) as LayerTableRecord;
        if (ltr != null) names.Add(ltr.Name);
    }
    Log("      VP-FROZEN (" + names.Count + "): " + string.Join(", ", names));
}

// do entities actually exist on those layers, and where?
Log("--- entities on HERO/TRACT layers (model space) ---");
var ms = (BlockTableRecord)Tx.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(Db), OpenMode.ForRead);
var counts = new Dictionary<string,int>();
var bounds = new Dictionary<string,string>();
foreach (ObjectId id in ms)
{
    var e = Tx.GetObject(id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
    if (e == null) continue;
    var n = e.Layer.ToUpper();
    if (!(n.Contains("HERO") || n.Contains("TRACT"))) continue;
    counts[e.Layer] = counts.ContainsKey(e.Layer) ? counts[e.Layer]+1 : 1;
    try { var ex = e.GeometricExtents;
        bounds[e.Layer] = "(" + ex.MinPoint.X.ToString("F1") + "," + ex.MinPoint.Y.ToString("F1") + ")-(" +
                          ex.MaxPoint.X.ToString("F1") + "," + ex.MaxPoint.Y.ToString("F1") + ")"; } catch { }
}
if (counts.Count == 0) Log("  NO ENTITIES on any HERO/TRACT layer in model space");
foreach (var kv in counts) Log("  " + kv.Value + " on '" + kv.Key + "'  last extents " + (bounds.ContainsKey(kv.Key) ? bounds[kv.Key] : "?"));

Result

Status
success
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260619 - 3625 Stonewall Tell Rd, Atlanta, GA 30349, USA\260619 - 3625 Stonewall Tell Rd ROTATE.dwg
Message
Executed C3D-260619-HEROVIS (0 entities touched).
Entities
Duration
500 ms
Civil 3D
25.0.0.0

Log

--- layers matching HERO/TRACT ---
  'SS-BOUNDARY TRACT B' off=False frozen=False locked=False plot=True color=5 vpdflt-frozen=False
  'SS-BOUNDARY TRACT A' off=False frozen=False locked=False plot=True color=5 vpdflt-frozen=False
  'SS-HERO TRACT B' off=False frozen=False locked=False plot=True color=5 vpdflt-frozen=False
  'SS-HERO TRACT A' off=False frozen=False locked=False plot=True color=5 vpdflt-frozen=False
  'SS-HERO TRACT A ANNO' off=False frozen=False locked=False plot=True color=5 vpdflt-frozen=False
  'SS-HERO TRACT B ANNO' off=False frozen=False locked=False plot=True color=5 vpdflt-frozen=False
  'SS-BOUNDARY TRACT NF' off=False frozen=False locked=False plot=True color=6 vpdflt-frozen=False
--- viewports on '22X17 C' ---
  Viewport h=213FC num=-1 on=True centre(11.11,8.37) w=42.37 h=16.86 scale=1:1.0
      no per-viewport frozen layers
  Viewport h=21534 num=-1 on=True centre(11.00,8.50) w=21.41 h=16.39 scale=1:60.6
      no per-viewport frozen layers
--- entities on HERO/TRACT layers (model space) ---
  6 on 'SS-HERO TRACT A ANNO'  last extents (2166629.0,1330596.8)-(2166646.8,1330638.9)
  1 on 'SS-BOUNDARY TRACT B'  last extents (2165372.3,1329914.0)-(2165683.9,1330669.9)
  5 on 'SS-HERO TRACT B ANNO'  last extents (2166514.7,1330347.2)-(2166527.6,1330383.9)
  1 on 'SS-HERO TRACT B'  last extents (2166514.1,1330003.9)-(2166819.3,1330757.4)
  2 on 'SS-BOUNDARY TRACT A'  last extents (2165133.7,1329549.3)-(2165585.2,1329785.9)
  1 on 'SS-HERO TRACT A'  last extents (2166619.5,1330505.8)-(2166868.3,1330720.3)
  1 on 'SS-BOUNDARY TRACT NF'  last extents (2166393.5,1330057.1)-(2166529.8,1330757.4)

Notes

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

No notes yet.