<?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 Re: What is the difference between .Net created and Interop object created layer in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/what-is-the-difference-between-net-created-and-interop-object/m-p/3751063#M51655</link>
    <description>&lt;P&gt;Are you sure you're asking your question in the right place ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There's plenty of implementation differences between AutoCAD and other look-a-like APIs, and I don't know if this is the best place to ask about them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 11 Jan 2013 14:42:36 GMT</pubDate>
    <dc:creator>DiningPhilosopher</dc:creator>
    <dc:date>2013-01-11T14:42:36Z</dc:date>
    <item>
      <title>What is the difference between .Net created and Interop object created layer?</title>
      <link>https://forums.autodesk.com/t5/net-forum/what-is-the-difference-between-net-created-and-interop-object/m-p/3750085#M51653</link>
      <description>&lt;P&gt;Hi Guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have used VB.net created a layer. then place a polyline on this layer. Then I use Teigh object export the drawing to bmp&lt;/P&gt;&lt;P&gt;oHost =&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" size="2"&gt;&lt;FONT color="#0000ff" size="2"&gt;New&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt; TeighaX.OdaHostApp &lt;/FONT&gt;&lt;FONT color="#008000" size="2"&gt;&lt;FONT color="#008000" size="2"&gt;'Create the DDX application&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;oBmp =&lt;/P&gt;&lt;P&gt;&lt;FONT color="#0000ff" size="2"&gt;&lt;FONT color="#0000ff" size="2"&gt;New&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size="2"&gt; TeighaX.OdaBmpOut &lt;/FONT&gt;&lt;FONT color="#008000" size="2"&gt;&lt;FONT color="#008000" size="2"&gt;'Create the bmp-exporter&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#008000" size="2"&gt;&lt;FONT color="#008000" size="2"&gt;'Variable stores a reference to the current drawing&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;oDoc = oHost.Application.Documents.Open(strDrawingPath)&lt;/P&gt;&lt;P&gt;&lt;FONT color="#008000" size="2"&gt;&lt;FONT color="#008000" size="2"&gt;'Open a drawing from the specified dwg-file&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;oBmp.WriteFile(oDoc.Database, strThumbBMPPath)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This throw an error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However if I use COM Interop Object create a layer. place the same polyline on it. Then use the same code to export drawing to bmp. There is no error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think there must be different between .Net created layer to COM Interop created layer. Could anybody give me a hint? This drive me mad now.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here are code&lt;/P&gt;&lt;P&gt;VB.Net&lt;/P&gt;&lt;PRE&gt;    Public Function AutoCADCreateLayer(ByVal strLayerName As String, Optional ByVal lngLayerColour As Long = -1, _
                                       Optional ByVal blnLayerOn As Boolean = True, Optional ByVal blnLayerLocked As Boolean = False) As Boolean
        Dim db As Database = acApp.DocumentManager.MdiActiveDocument.Database

        Dim blnRt As Boolean
        Try
            Using lock As DocumentLock = Application.DocumentManager.MdiActiveDocument.LockDocument
                Using trans As Transaction = db.TransactionManager.StartTransaction
                    Dim objLayertb As LayerTable = db.LayerTableId.GetObject(OpenMode.ForWrite)
                    Dim objNewLayer As New LayerTableRecord
                    With objNewLayer
                        .Name = strLayerName
                        .Color = Autodesk.AutoCAD.Colors.Color.FromColorIndex(Autodesk.AutoCAD.Colors.ColorMethod.ByLayer, lngLayerColour)
                        '    .IsHidden = Not blnLayerOn
                        '   .IsLocked = blnLayerLocked
                    End With
                    objLayertb.UpgradeOpen()
                    Dim objNewLayerID As ObjectId = objLayertb.Add(objNewLayer)
                    trans.AddNewlyCreatedDBObject(objNewLayer, True)
                    db.Clayer = objNewLayerID
                    trans.Commit()
                End Using

                blnRt = True
            End Using
        Catch ex As Exception
            acApp.ShowAlertDialog("Error in create layer: " &amp;amp; ex.Message)
            Debug.Assert(False)

            blnRt = False
        Catch ex As SystemException
            acApp.ShowAlertDialog("Erro in create layer: " &amp;amp; ex.Message)
            Debug.Assert(False)

            blnRt = False

        End Try
        Return blnRt
    End Function&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;COM Interop&lt;/P&gt;&lt;PRE&gt;Dim objCOMDrawing As Autodesk.AutoCAD.Interop.AcadDocument = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.AcadDocument

objCOMDrawing.Layers.Add("mylayername")&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks very much&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jan 2013 14:28:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/what-is-the-difference-between-net-created-and-interop-object/m-p/3750085#M51653</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2013-01-10T14:28:14Z</dc:date>
    </item>
    <item>
      <title>Re: What is the difference between .Net created and Interop object created layer</title>
      <link>https://forums.autodesk.com/t5/net-forum/what-is-the-difference-between-net-created-and-interop-object/m-p/3750380#M51654</link>
      <description>&lt;P&gt;If you're adding layer in the current document&lt;/P&gt;&lt;P&gt;me think you need to remove" using LockDocument.. " code block from there,&lt;/P&gt;&lt;P&gt;just a guess, sorry&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jan 2013 19:07:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/what-is-the-difference-between-net-created-and-interop-object/m-p/3750380#M51654</guid>
      <dc:creator>Hallex</dc:creator>
      <dc:date>2013-01-10T19:07:33Z</dc:date>
    </item>
    <item>
      <title>Re: What is the difference between .Net created and Interop object created layer</title>
      <link>https://forums.autodesk.com/t5/net-forum/what-is-the-difference-between-net-created-and-interop-object/m-p/3751063#M51655</link>
      <description>&lt;P&gt;Are you sure you're asking your question in the right place ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There's plenty of implementation differences between AutoCAD and other look-a-like APIs, and I don't know if this is the best place to ask about them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jan 2013 14:42:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/what-is-the-difference-between-net-created-and-interop-object/m-p/3751063#M51655</guid>
      <dc:creator>DiningPhilosopher</dc:creator>
      <dc:date>2013-01-11T14:42:36Z</dc:date>
    </item>
    <item>
      <title>Re: What is the difference between .Net created and Interop object created layer</title>
      <link>https://forums.autodesk.com/t5/net-forum/what-is-the-difference-between-net-created-and-interop-object/m-p/3751388#M51656</link>
      <description>&lt;P&gt;What type of error is shown? If it is in one of your catch statements what does ex.message say?&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jan 2013 19:43:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/what-is-the-difference-between-net-created-and-interop-object/m-p/3751388#M51656</guid>
      <dc:creator>michael_robertson</dc:creator>
      <dc:date>2013-01-11T19:43:48Z</dc:date>
    </item>
  </channel>
</rss>

