In this post, I will show you how to create a new "Point Description Key sets" and add Point code using wildcards "*".
//start a transaction
using (Transaction trans = db.TransactionManager.StartTransaction())
{
// Access the collection of all Description key sets in a document
PointDescriptionKeySetCollection pointDescKeySetColl = PointDescriptionKeySetCollection.GetPointDescriptionKeySets(db);
// Add a new Descp. Key Sets
ObjectId PointDescKeySetsId = pointDescKeySetColl.Add("ADN_Point_Desc_Key");
PointDescriptionKeySet pointDescKeySet = trans.GetObject(PointDescKeySetsId, OpenMode.ForWrite) as PointDescriptionKeySet;
// Create a new key in the set with code = "TR*"
// The wildcards “?” and “*” are allowed in the code.
ObjectId pointDescKeyId = pointDescKeySet.Add("TR*");
PointDescriptionKey pointDescKey = trans.GetObject(pointDescKeyId, OpenMode.ForWrite) as PointDescriptionKey;
// set a specific Style and Label style
// in the following line we are presuming a Point Style named "Tree" exists in the DWG file
pointDescKey.StyleId = civilDoc.Styles.PointStyles["Tree"];
pointDescKey.ApplyStyleId = true;
// in the following line we are presuming a Point Label Style
// named "Point#-Elevation-Description" exists in the DWG file
pointDescKey.LabelStyleId = civilDoc.Styles.LabelStyles.PointLabelStyles.LabelStyles["Point#-Elevation-Description"];
pointDescKey.ApplyLabelStyleId = true;
trans.Commit();
}
Once you build your application using the above code snippet and run the custom command in Civil 3D 2013, you should see a new Point Description Key sets added to the collection like the screenshot shown below -
Hope this helps!