C3D-260619-HEROPARENT · What are the HERO/TRACT entities attached to done
Read-only: entity types on the HERO/TRACT layers and, for Civil 3D labels, the parent object and its layer; plus parcels/sites and what sits on C-PROP-LINE.
C# payload
// READ-ONLY: identify the HERO/TRACT entities and what they are attached to.
// Civil 3D labels follow their PARENT object's visibility - if the parcel segments are on
// C-PROP-LINE, turning that layer off hides the labels no matter what layer the labels are on.
var ms = (BlockTableRecord)Tx.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(Db), OpenMode.ForRead);
bool IsHero(string s) { var u = s.ToUpper(); return u.Contains("HERO") || u.Contains("TRACT"); }
Log("--- HERO/TRACT entities: what ARE they? ---");
foreach (ObjectId id in ms)
{
var e = Tx.GetObject(id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
if (e == null || !IsHero(e.Layer)) continue;
string extra = "";
var lbl = e as Autodesk.Civil.DatabaseServices.Label;
if (lbl != null)
{
try {
var pid = lbl.FeatureId;
if (!pid.IsNull) {
var pe = Tx.GetObject(pid, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
extra = " PARENT=" + (pe == null ? "?" : pe.GetType().Name + " on layer '" + pe.Layer + "'");
} else extra = " PARENT=none";
} catch (System.Exception ex) { extra = " (parent: " + ex.Message + ")"; }
}
Log(" " + e.GetType().Name + " h=" + e.Handle + " layer='" + e.Layer + "'" + extra);
}
Log("--- parcels / sites and their layers ---");
var cdoc = CivilDoc;
foreach (ObjectId sid in cdoc.GetSiteIds())
{
var site = Tx.GetObject(sid, OpenMode.ForRead) as Site;
if (site == null) continue;
Log(" Site '" + site.Name + "'");
foreach (ObjectId pid in site.GetParcelIds())
{
var p = Tx.GetObject(pid, OpenMode.ForRead) as Parcel;
if (p == null) continue;
Log(" Parcel '" + p.Name + "' layer='" + p.Layer + "' area=" + p.Area.ToString("F0"));
}
}
Log("--- what IS on C-PROP-LINE ---");
var kinds = new Dictionary<string,int>();
foreach (ObjectId id in ms)
{
var e = Tx.GetObject(id, OpenMode.ForRead) as Autodesk.AutoCAD.DatabaseServices.Entity;
if (e == null || e.Layer != "C-PROP-LINE") continue;
var k = e.GetType().Name;
kinds[k] = kinds.ContainsKey(k) ? kinds[k]+1 : 1;
}
if (kinds.Count == 0) Log(" (nothing in model space on C-PROP-LINE)");
foreach (var kv in kinds) Log(" " + kv.Value + " " + kv.Key);
Result
Log
--- HERO/TRACT entities: what ARE they? ---
ParcelSegmentLabel h=20CFD layer='SS-HERO TRACT A ANNO' PARENT=ParcelSegment on layer 'C-PROP-LINE'
ParcelSegmentLabel h=20CFE layer='SS-HERO TRACT A ANNO' PARENT=ParcelSegment on layer 'C-PROP-LINE'
ParcelSegmentLabel h=20CFF layer='SS-HERO TRACT A ANNO' PARENT=ParcelSegment on layer 'C-PROP-LINE'
ParcelSegmentLabel h=2103E layer='SS-HERO TRACT A ANNO' PARENT=ParcelSegment on layer 'C-PROP-LINE'
Polyline h=21075 layer='SS-BOUNDARY TRACT B'
ParcelSegmentLabel h=21078 layer='SS-HERO TRACT B ANNO' PARENT=ParcelSegment on layer 'C-PROP-LINE'
ParcelSegmentLabel h=2107A layer='SS-HERO TRACT A ANNO' PARENT=ParcelSegment on layer 'C-PROP-LINE'
ParcelSegmentLabel h=2107B layer='SS-HERO TRACT A ANNO' PARENT=ParcelSegment on layer 'C-PROP-LINE'
ParcelSegmentLabel h=2107C layer='SS-HERO TRACT B ANNO' PARENT=ParcelSegment on layer 'C-PROP-LINE'
ParcelSegmentLabel h=2107D layer='SS-HERO TRACT B ANNO' PARENT=ParcelSegment on layer 'C-PROP-LINE'
ParcelSegmentLabel h=2107E layer='SS-HERO TRACT B ANNO' PARENT=ParcelSegment on layer 'C-PROP-LINE'
ParcelSegmentLabel h=2107F layer='SS-HERO TRACT B ANNO' PARENT=ParcelSegment on layer 'C-PROP-LINE'
Polyline h=2167A layer='SS-HERO TRACT B'
Polyline h=216AD layer='SS-BOUNDARY TRACT A'
Polyline h=216BA layer='SS-HERO TRACT A'
Ole2Frame h=21896 layer='SS-BOUNDARY TRACT A'
Polyline h=2190F layer='SS-BOUNDARY TRACT NF'
--- parcels / sites and their layers ---
Site 'SITE'
Parcel 'Property : 26' layer='SS-BOUNDARY LAND LOT' area=43299
Parcel 'TRACT "B"' layer='C-PROP' area=144351
Site '{DBBA330E-324D-4F34-97479ABEBDCF917D}|2'
Site 'CURB'
Site 'CURB|1'
Site '{DBBA330E-324D-4F34-97479ABEBDCF917D}|3'
Site '{DBBA330E-324D-4F34-97479ABEBDCF917D}'
Site '{DBBA330E-324D-4F34-97479ABEBDCF917D}|4'
Site '{DBBA330E-324D-4F34-97479ABEBDCF917D}|1'
--- what IS on C-PROP-LINE ---
3 ParcelSegmentNotes
What worked, what didn't, job-specific gotchas — flagged notes feed the recipes.
No notes yet.