Check needed to determine if a text is present in a Linetype using .NET


By Deepak Nadig

Recently, an ADN partner requested for a method to check if a
text is contained in a Linetype before extracting the

To extract a text, LinetypeTableRecord.TextAt is used and it
returns eNotApplicable error when text is not present at index
in the record. To avoid this, null id check using
LinetypeTableRecord.ShapeStyleAt can be used. This method
returns null text is not present at an index in the

Here is a quick sample to check if text is present prior to
extraction of the text :  

public void lineTypeText() {
Document doc = Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Transaction tr = db.TransactionManager.StartTransaction();

Editor ed = doc.Editor;
using (tr) {
DBObject tmpObj = tr.GetObject(db.LinetypeTableId, OpenMode.ForRead);
LinetypeTable pLineTable = (LinetypeTable)tmpObj;
if ((pLineTable != null)) {
        foreach (ObjectId tblRecId in pLineTable) {

                LinetypeTableRecord pLineType = (LinetypeTableRecord)tr.GetObject(tblRecId, OpenMode.ForRead);
                if ((pLineType != null)) {
                        for (int dash = 0; dash < pLineType.NumDashes; dash++) {
                                /* LinetypeTableRecord.ShapeStyleAt returns the ObjectId of the TextStyleTableRecord of the shape 
                          (or textStyle if it's a text string instead of a shape) at position index in the LinetypeTableRecord.
                          If there is no shape or text at index, then Null is returned.*/
                                ObjectId objIdShape = pLineType.ShapeStyleAt(dash);
                                if (objIdShape != ObjectId.Null) {
                                        string pText = "";
                                        pText = pLineType.TextAt(dash);
                                        if (pText == "") {

Read More