Display Manager elements can have style associated with them.
DisplayManagement.Style is the base class for all the style classes. It is based on AutoCAD.DatabaseServices.DBObject, so it must be managed using AutoCAD transactions. The available style classes are:
Element.AddStyle() creates a reference from the element to the style object in the database. Multiple elements can refer to the same style object.
To create a new style, call its Create() method. Set the appropriate properties for the style type. Save the style in the database and add it to an element. For example, the following creates a new entity style and assigns it to a layer element:
Try trans = activeDoc.TransactionManager.StartTransaction() ' Open the element for write, so the style can be added Dim layer As Element = trans.GetObject(layerId, _ OpenMode.ForWrite) ' Pass 0.0 for the current scale Dim styleRefIterator As StyleReferenceIterator = _ layer.GetStyleReferenceIterator(0.0, True, True) ' Add the style Dim styleEntity As EntityStyle = EntityStyle.Create() ' Set style properties Dim color As Autodesk.AutoCAD.Colors.Color = _ color.FromColorIndex( _ Autodesk.AutoCAD.Colors.ColorMethod.None, 5) styleEntity.Color = color styleEntity.Name = styleName Dim id As ObjectId id = layer.AddStyle(styleEntity, styleRefIterator) trans.AddNewlyCreatedDBObject(styleEntity, True) trans.Commit() trans = Nothing Catch e As System.Exception ' Process exception Finally If Not trans Is Nothing Then trans.Abort() trans = Nothing End If End Try