This is in continuation to my previous post on StandardPointGroupQuery. In this post I am trying to show a simple way to build a PointGroup using CustomPointGroupQuery. The CustomPointGroupQuery lets you specify a query string directly. This method of query creation allows you to create nested queries that cannot be specified using the StandardPointGroupQuery object.
Here is a C# code snippet which demonstrates how to create a PointGroup using CustomPointGroupQuery object.
// Check if the pointGrpName already exists before trying to add it
ObjectId pointGrpId = civilDoc.PointGroups.Add(pointGrpName);
PointGroup pointGrp = pointGrpId.GetObject(OpenMode.ForWrite) as PointGroup;
// Build a quesry using CustomPointGroupQuery object
// Query conditions used below are specific to Civil 3D Tutorial DWG file "Points-3.dwg"
CustomPointGroupQuery customPointGrpQry = new CustomPointGroupQuery();
string queryString = "(RawDescription='TO*') AND (PointNumber>=600 AND PointNumber<=1000) AND PointElevation>=100.00 ";
customPointGrpQry.QueryString = queryString;
pointGrp.SetQuery(customPointGrpQry);
Hope this is useful to you!