← Inbox

C3D-260619-DELMH1B · Delete point group MH.1 done

Removes duplicate point group MH.1 via PointGroupCollection.Remove(name). Group definition only - verifies CogoPoint count is unchanged.

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

C# payload

// Delete the duplicate point group "MH.1".
// Use PointGroupCollection.Remove(name) - NOT Erase() on the ObjectId, which fails with
// eNullObjectId (verified by reflecting AeccDbMgd: PointGroupCollection exposes
// Remove(ObjectId) / Remove(String) / RemoveAt(int)).
// NOTE: PointGroup.DeletePoints() also exists and WOULD destroy the CogoPoints - do not use it.
// Removing a group deletes only the group definition; the points are untouched (verified by
// count before/after). Host owns Tx; host regens after commit.
const string NAME = "MH.1";
var cdoc = CivilDoc;
int before = (int)cdoc.CogoPoints.Count;
Log("CogoPoints before: " + before);

bool found = false;
foreach (ObjectId id in cdoc.PointGroups)
{
    var pg = Tx.GetObject(id, OpenMode.ForRead) as PointGroup;
    if (pg != null && pg.Name == NAME)
    {
        uint[] had; try { had = pg.GetPointNumbers(); } catch { had = new uint[0]; }
        Log("removing '" + NAME + "' (it listed " + had.Length + " points)");
        found = true;
        break;
    }
}
if (!found) { Log("'" + NAME + "' not found."); return; }

cdoc.PointGroups.Remove(NAME);

bool stillThere = false;
int left = 0;
foreach (ObjectId id in cdoc.PointGroups)
{
    var pg = Tx.GetObject(id, OpenMode.ForRead) as PointGroup;
    if (pg == null) continue;
    left++;
    if (pg.Name == NAME) stillThere = true;
}
int after = (int)cdoc.CogoPoints.Count;
Log("point groups now: " + left + "; '" + NAME + "' present=" + stillThere);
Log("CogoPoints after: " + after + (after == before ? " (unchanged - verified)" : " (CHANGED! " + before + " -> " + after + ")"));

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-DELMH1B (0 entities touched).
Entities
Duration
496 ms
Civil 3D
25.0.0.0

Log

CogoPoints before: 374
removing 'MH.1' (it listed 6 points)
point groups now: 45; 'MH.1' present=False
CogoPoints after: 374 (unchanged - verified)

Notes

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

No notes yet.