← Inbox

C3D-260612-PGCOPY · Copy 23 point groups from SS_BLOCK_22X17 done

Recreates the 23 point groups read out of SS_BLOCK_22X17.dwg with their include/exclude filters (Display [SPECIFIC], _All Points and TBC excluded). Skips any that already exist.

Script file
C3D-260612-PGCOPY.cs
Target
260612 · model space
Author
claude
Approved
yes · reviewer
Timeout
180s

C# payload

// Recreate the point groups copied out of SS_BLOCK_22X17.dwg, with their include/exclude
// filters. 23 groups - "Display [SPECIFIC]", "_All Points" (built in to every drawing) and
// "TBC" were excluded per the user.
//
// API verified by reflecting AeccDbMgd: PointGroupCollection.Add(name) returns the ObjectId;
// the filter lives on a StandardPointGroupQuery set via PointGroup.SetQuery().
// Skips any group that already exists rather than duplicating it, so this is safe to re-run.
// Host owns Tx; host regens after commit.
var cd = CivilDoc;

var defs = new (string name, string incNum, string incRawDesc, string excNum, string excRawDesc)[] {
    (@"IPA", @"", @"*IPA*", @"", @""),
    (@"NORTHING_EASTING", @"", @"IPP,CP", @"", @""),
    (@"UTIL", @"", @"*FLAG*,LP,CO,WM,A\C,clean out,HAM*,POWER*,TRAFFIC*,*SIG*,*CLEAN*,TRAFF*,*GAS*", @"262,263,264", @""),
    (@"CP", @"", @"CP", @"205", @""),
    (@"GAS VALVE", @"", @"GV", @"", @""),
    (@"IPF NS", @"", @"IPP,*IPF*,SPIKE,*IPS*,CTP,*OTP*,FENCE POST,ANGLE*,PIPE", @"205", @""),
    (@"MH", @"", @"*MH*,*CB*,*SEWER*", @"268", @""),
    (@"DI CB", @"", @"*DI*,*CB*", @"", @""),
    (@"TREES", @"", @"*HW*", @"", @""),
    (@"PP", @"", @"*PP*", @"", @""),
    (@"FH", @"", @"FH", @"", @""),
    (@"WV", @"", @"WV", @"", @""),
    (@"POB", @"", @"POB", @"205", @""),
    (@"FF", @"", @"FF*", @"135,136,137,84", @""),
    (@"No Display", @">0", @"", @"", @""),
    (@"CON", @"", @"*CON*", @"", @""),
    (@"TOPO", @">0", @"", @"", @"CP,IPP"),
    (@"FENCE", @"", @"*FC*,*FL*", @"", @""),
    (@"GAS", @"", @"*GAS*", @"", @""),
    (@"CL", @"", @"*CL*", @"", @""),
    (@"WALL ELEV", @"", @"*WALL*", @"131-137,173-176,187-189,199-200,202-203,206-213,218-219,221,223,230,234-241,249-250", @""),
    (@"WALL", @"", @"*WALL*", @"", @""),
    (@"BUILDING", @"", @"LP,*BLDG*,*HC*", @"", @"")
};

var existing = new List<string>();
foreach (ObjectId id in cd.PointGroups) {
    var pg0 = Tx.GetObject(id, OpenMode.ForRead) as PointGroup;
    if (pg0 != null) existing.Add(pg0.Name);
}
Log("drawing has " + (int)cd.CogoPoints.Count + " points, " + existing.Count + " existing groups");

int made = 0, skipped = 0, failed = 0;
foreach (var d in defs)
{
    if (existing.Contains(d.name)) { Log("  SKIP '" + d.name + "' - already exists"); skipped++; continue; }
    try
    {
        var gid = cd.PointGroups.Add(d.name);
        var pg = (PointGroup)Tx.GetObject(gid, OpenMode.ForWrite);

        var q = new StandardPointGroupQuery();
        q.IncludeNumbers          = d.incNum;
        q.IncludeRawDescriptions  = d.incRawDesc;
        q.ExcludeNumbers          = d.excNum;
        q.ExcludeRawDescriptions  = d.excRawDesc;
        pg.SetQuery(q);

        uint[] nums; try { nums = pg.GetPointNumbers(); } catch { nums = new uint[0]; }
        Log("  created '" + d.name + "'  ->  " + nums.Length + " point(s) match here");
        made++;
    }
    catch (System.Exception ex) { Log("  FAILED '" + d.name + "': " + ex.Message); failed++; }
}

int total = 0;
foreach (ObjectId id in cd.PointGroups) {
    var pg2 = Tx.GetObject(id, OpenMode.ForRead) as PointGroup;
    if (pg2 != null) total++;
}
Log("created " + made + ", skipped " + skipped + ", failed " + failed + "; drawing now has " + total + " point groups (verified)");

Result

Status
success
Drawing file
C:\Users\sanja\OneDrive\_SurveyDisco\260613 - 5030 E Lake Pkwy, Stockbridge, GA 30281, USA\CSTORE WATER ABS-260612_SHEET.dwg
Message
Executed C3D-260612-PGCOPY (0 entities touched).
Entities
Duration
650 ms
Civil 3D
25.0.0.0

Log

drawing has 576 points, 4 existing groups
  created 'IPA'  ->  0 point(s) match here
  created 'NORTHING_EASTING'  ->  0 point(s) match here
  created 'UTIL'  ->  16 point(s) match here
  created 'CP'  ->  0 point(s) match here
  created 'GAS VALVE'  ->  0 point(s) match here
  created 'IPF NS'  ->  0 point(s) match here
  created 'MH'  ->  27 point(s) match here
  created 'DI CB'  ->  15 point(s) match here
  created 'TREES'  ->  0 point(s) match here
  created 'PP'  ->  2 point(s) match here
  created 'FH'  ->  5 point(s) match here
  created 'WV'  ->  9 point(s) match here
  created 'POB'  ->  0 point(s) match here
  created 'FF'  ->  0 point(s) match here
  created 'No Display'  ->  576 point(s) match here
  created 'CON'  ->  51 point(s) match here
  created 'TOPO'  ->  576 point(s) match here
  created 'FENCE'  ->  0 point(s) match here
  created 'GAS'  ->  0 point(s) match here
  created 'CL'  ->  27 point(s) match here
  created 'WALL ELEV'  ->  6 point(s) match here
  created 'WALL'  ->  6 point(s) match here
  created 'BUILDING'  ->  9 point(s) match here
created 23, skipped 0, failed 0; drawing now has 27 point groups (verified)

Notes

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

No notes yet.