<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How do I set the color index and layer of newly created dimension style in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/how-do-i-set-the-color-index-and-layer-of-newly-created/m-p/4335186#M48620</link>
    <description>&lt;P&gt;Hi all, I'm having a bit of a problem struggling with creating new dimension style using vee bee dot net, in AutoCAD 2010 environment. I am particularly trying to figure out how to set the newly created dimension style to color white, and to assign it a specific layer (for example, a layer called "test").&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know what the code syntax is to accomplish this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I post the code below for what I have done thus far:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;Public Shared Sub addDimensionStyle(ByVal strDimStyle As String)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;Dim acDb As Database = HostApplicationServices.WorkingDatabase&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;Using acTrans As Transaction = acDb.TransactionManager.StartTransaction()&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;Dim dimTbl As DimStyleTable = acDb.DimStyleTableId.GetObject(OpenMode.ForWrite)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;Dim dimTblRec As DimStyleTableRecord = Nothing&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;If dimTbl.Has(strDimStyle) = True Then&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;dimTblRec = dimTbl(strDimStyle).GetObject(OpenMode.ForRead)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;Else&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;dimTblRec = New DimStyleTableRecord()&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;dimTblRec.Name = strDimStyle&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;dimTbl.Add(dimTblRec)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;' Set the color index of the new dimension style here...&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;' Set the layer of the new dimension style here...&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;acTrans.AddNewlyCreatedDBObject(dimTblRec, True)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;End If&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;acTrans.Commit()&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;End Using&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;End Sub&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks in advance...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cat&lt;/P&gt;</description>
    <pubDate>Thu, 18 Jul 2013 18:00:55 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2013-07-18T18:00:55Z</dc:date>
    <item>
      <title>How do I set the color index and layer of newly created dimension style</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-do-i-set-the-color-index-and-layer-of-newly-created/m-p/4335186#M48620</link>
      <description>&lt;P&gt;Hi all, I'm having a bit of a problem struggling with creating new dimension style using vee bee dot net, in AutoCAD 2010 environment. I am particularly trying to figure out how to set the newly created dimension style to color white, and to assign it a specific layer (for example, a layer called "test").&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone know what the code syntax is to accomplish this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I post the code below for what I have done thus far:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;Public Shared Sub addDimensionStyle(ByVal strDimStyle As String)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;Dim acDb As Database = HostApplicationServices.WorkingDatabase&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;Using acTrans As Transaction = acDb.TransactionManager.StartTransaction()&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;Dim dimTbl As DimStyleTable = acDb.DimStyleTableId.GetObject(OpenMode.ForWrite)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;Dim dimTblRec As DimStyleTableRecord = Nothing&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;If dimTbl.Has(strDimStyle) = True Then&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;dimTblRec = dimTbl(strDimStyle).GetObject(OpenMode.ForRead)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;Else&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;dimTblRec = New DimStyleTableRecord()&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;dimTblRec.Name = strDimStyle&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;dimTbl.Add(dimTblRec)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;' Set the color index of the new dimension style here...&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;' Set the layer of the new dimension style here...&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;acTrans.AddNewlyCreatedDBObject(dimTblRec, True)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;End If&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#0000FF"&gt;acTrans.Commit()&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;End Using&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000FF"&gt;End Sub&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks in advance...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cat&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2013 18:00:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-do-i-set-the-color-index-and-layer-of-newly-created/m-p/4335186#M48620</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-07-18T18:00:55Z</dc:date>
    </item>
    <item>
      <title>Re: How do I set the color index and layer of newly created dimension style</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-do-i-set-the-color-index-and-layer-of-newly-created/m-p/4335432#M48621</link>
      <description>Take a look at this article:&lt;BR /&gt;&lt;A target="_blank" href="http://through-the-interface.typepad.com/through_the_interface/2010/01/creating-an-autocad-layer-using-net.html"&gt;http://through-the-interface.typepad.com/through_the_interface/2010/01/creating-an-autocad-layer-using-net.html&lt;/A&gt;</description>
      <pubDate>Thu, 18 Jul 2013 21:14:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-do-i-set-the-color-index-and-layer-of-newly-created/m-p/4335432#M48621</guid>
      <dc:creator>Hallex</dc:creator>
      <dc:date>2013-07-18T21:14:03Z</dc:date>
    </item>
    <item>
      <title>Re: How do I set the color index and layer of newly created dimension style</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-do-i-set-the-color-index-and-layer-of-newly-created/m-p/4335444#M48622</link>
      <description>&lt;P&gt;Found one in my codes:&lt;/P&gt;&lt;PRE&gt;        &amp;lt;CommandMethod("hanno")&amp;gt; _
        Public Sub testCreateLayer()
            CreateLayer("H-ANNO-MARK", "HIDDEN2", 14)
        End Sub
        Private Sub CreateLayer(layerName As String, ltpname As String, color As Short)
            Dim layerId As ObjectId
            Dim ltrid As ObjectId = ObjectId.Null
            Dim db As Database = HostApplicationServices.WorkingDatabase
            Using tr As Transaction = db.TransactionManager.StartTransaction()
                Dim lt As LayerTable = DirectCast(tr.GetObject(db.LayerTableId, OpenMode.ForRead), LayerTable)
                If lt.Has(layerName) Then
                    layerId = lt(layerName)
                Else
                    Dim ltr As New LayerTableRecord()
                    ltr.Name = layerName
                    ltr.Color = Autodesk.AutoCAD.Colors.Color.FromColorIndex(ColorMethod.ByAci, color)
                    Dim ltt As LinetypeTable = TryCast(tr.GetObject(db.LinetypeTableId, OpenMode.ForRead), LinetypeTable)

                    If ltt.Has(ltpname) Then
                        ltrid = ltt(ltpname)

                        ltt.UpgradeOpen()


                        ltr.LinetypeObjectId = ltrid
                    Else
                        LoadLineType(ltpname)
                        Dim lttr As LinetypeTableRecord = TryCast(tr.GetObject(ltt(ltpname), OpenMode.ForRead, False), LinetypeTableRecord)
                        ltr.LinetypeObjectId = ltt(ltpname)
                    End If
                    lt.UpgradeOpen()
                    layerId = lt.Add(ltr)
                    tr.AddNewlyCreatedDBObject(ltr, True)
                    db.Clayer = layerId
                End If
                tr.Commit()
            End Using
        End Sub

        '----------------------------------------------------------------------

        Public Shared Sub LoadLineType(ltname As String)
            Dim db As Database = HostApplicationServices.WorkingDatabase

            Using tr As Transaction = db.TransactionManager.StartTransaction()


                Dim tbl As LinetypeTable = DirectCast(tr.GetObject(db.LinetypeTableId, OpenMode.ForRead), LinetypeTable)

                If Not tbl.Has(ltname) Then
                    db.LoadLineTypeFile(ltname, "acad.lin")
                End If
                tr.Commit()
            End Using
        End Sub&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2013 21:23:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-do-i-set-the-color-index-and-layer-of-newly-created/m-p/4335444#M48622</guid>
      <dc:creator>Hallex</dc:creator>
      <dc:date>2013-07-18T21:23:42Z</dc:date>
    </item>
    <item>
      <title>Re: How do I set the color index and layer of newly created dimension style</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-do-i-set-the-color-index-and-layer-of-newly-created/m-p/4335452#M48623</link>
      <description>&lt;P&gt;Thanks for the quick reply, Hallex... However, my problem is not creating a new layer; my problem is assigning a layer and color index to the dimension style I created in the code I posted. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I looked through the pop up options for the dimension style table record newly created, and I see options like Dimclrd, Dimclre and I don't see an option for Layer (for example dimTblRec.Layer="Test Layer", dimTblRec.colorIndex=7)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My task is to create a dimension style that will always be on layer "DImension Layer" and will always be on color white.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I only came as far as creating the dimension style, then I am stuck. Any ideas?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks in advance.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2013 21:40:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-do-i-set-the-color-index-and-layer-of-newly-created/m-p/4335452#M48623</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-07-18T21:40:53Z</dc:date>
    </item>
    <item>
      <title>Re: How do I set the color index and layer of newly created dimension style</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-do-i-set-the-color-index-and-layer-of-newly-created/m-p/4335466#M48624</link>
      <description>&lt;P&gt;Layer is a property of dimension entities, not dimension styles.&amp;nbsp; In order for them to always be on a specific layer, you will need to create your own dimension object commands, or react to events fired when they are added to the drawing.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2013 21:55:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-do-i-set-the-color-index-and-layer-of-newly-created/m-p/4335466#M48624</guid>
      <dc:creator>dgorsman</dc:creator>
      <dc:date>2013-07-18T21:55:56Z</dc:date>
    </item>
    <item>
      <title>Re: How do I set the color index and layer of newly created dimension style</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-do-i-set-the-color-index-and-layer-of-newly-created/m-p/4335535#M48625</link>
      <description>&lt;P&gt;Thanks, that worked!&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2013 23:52:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-do-i-set-the-color-index-and-layer-of-newly-created/m-p/4335535#M48625</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-07-18T23:52:16Z</dc:date>
    </item>
  </channel>
</rss>

