← Inbox

C3D-260619-PGDEPS · Check point group dependencies error

Read-only: which surfaces are built from point groups, and whether the .1 duplicate groups carry style overrides, before deleting any of them.

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

C# payload

// READ-ONLY: before deleting any ".1" point group, check what depends on them.
// Surfaces built from point groups, and the point-group display/override chain, would break.
var cdoc = CivilDoc;
Log("CogoPoints in drawing: " + cdoc.CogoPoints.Count);

var dot = new List<string>();
foreach (ObjectId id in cdoc.PointGroups)
{
    var pg = Tx.GetObject(id, OpenMode.ForRead) as PointGroup;
    if (pg == null) continue;
    if (pg.Name.EndsWith(".1")) dot.Add(pg.Name);
}
Log(dot.Count + " groups ending in '.1': " + string.Join(", ", dot));

// surfaces and what they are built from
Log("--- surfaces ---");
foreach (ObjectId sid in cdoc.GetSurfaceIds())
{
    var surf = Tx.GetObject(sid, OpenMode.ForRead) as Autodesk.Civil.DatabaseServices.Surface;
    if (surf == null) continue;
    Log("  surface '" + surf.Name + "' type=" + surf.GetType().Name);
    var tin = surf as TinSurface;
    if (tin != null)
    {
        try {
            var defs = tin.PointGroupsDefinition;
            foreach (ObjectId g in defs)
            {
                var pg = Tx.GetObject(g, OpenMode.ForRead) as PointGroup;
                Log("      built from point group: '" + (pg == null ? "?" : pg.Name) + "'");
            }
        } catch (System.Exception ex) { Log("      (pointgroup defs: " + ex.Message + ")"); }
    }
}

// does any group carry style/label overrides that others inherit?
Log("--- group detail ---");
foreach (ObjectId id in cdoc.PointGroups)
{
    var pg = Tx.GetObject(id, OpenMode.ForRead) as PointGroup;
    if (pg == null || !pg.Name.EndsWith(".1")) continue;
    uint[] nums; try { nums = pg.GetPointNumbers(); } catch { nums = new uint[0]; }
    bool ovr = false;
    try { ovr = pg.IsPointStyleOverridden || pg.IsPointLabelStyleOverridden; } catch { }
    Log("  '" + pg.Name + "' pts=" + nums.Length + " styleOverride=" + ovr);
}

Result

Status
error
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260619 - 3625 Stonewall Tell Rd, Atlanta, GA 30349, USA\260619 - 3625 Stonewall Tell Rd ROTATE.dwg
Message
Compile error: (27,36): error CS1579: foreach statement cannot operate on variables of type 'SurfaceDefinitionPointGroups' because 'SurfaceDefinitionPointGroups' does not contain a public instance or extension definition for 'GetEnumerator'
Entities
Duration
683 ms
Civil 3D
25.0.0.0

Notes

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

No notes yet.