Using CogoPoint.ApplyDescriptionKeys() to apply DescriptionKeys to a CogoPoint

By Partha Sarkar

As you know, we can use description keys to automatically control point appearance and some point properties when creating or importing a point into a drawing.

We use description keys to automatically control some drawing point properties, such as the appearance of a point in the drawing at the time of import points or when we create point in the drawing. Before you create drawing points using description keys, create a series of description keys. Then, when you create or import a drawing point, the raw description for the point specifies which description key is used to create the point in the drawing. The properties defined for that description key are applied to the point as it is added to the drawing.

AutoCAD Civil 3D provides a nice UI tool "Apply Description Keys" to apply  description keys to a single point or a collection of points.

Apply_Desc1

 

The following C# code snippet demonstrates how to apply description keys to a selected point after updating it's RawDescription value.

 

//start a transaction 
  using (Transaction trans = db.TransactionManager.StartTransaction())
  {
 
    //open the COGO Point 
    CogoPoint cogoPoint = trans.GetObject(per.ObjectId, OpenMode.ForRead) as CogoPoint;
 
    // Change it's RawDescription
    cogoPoint.RawDescription = "TREE";             
 
    // ApplyDescriptionKeys() to apply DescriptionKeys to a CogoPoint
    cogoPoint.ApplyDescriptionKeys();
 
    trans.Commit();
  }

 

Once you build your application using the above code snippet and run the custom command in Civil 3D 2013, you should see the Point appearance changed(like below ) :

Desc_applied

Hope this helps!


Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading