<?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: How do I add objects to a drawing NOT open in Acad? in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/how-do-i-add-objects-to-a-drawing-not-open-in-acad/m-p/2859946#M62638</link>
    <description>&lt;P&gt;I cleaned up the code and showed where I added the Savas&lt;/P&gt;&lt;P&gt;I get an "eFileSharingViolation" error when the program hits the myDB2.SaveAs line.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;        dbPath = "O:\projects\Test Location\Wallframingissue10\Views\View-Partition1.dwg"
        Using myDB2 As Database = New Database(False, False)
            myDB2.ReadDwgFile(dbPath, FileOpenMode.OpenForReadAndWriteNoShare, True, "")
            Dim vptLL As Point3d = New Point3d(0, 0, 0)
            Dim vptUL As Point3d = New Point3d(vptLL.X, 12, 0)
            Dim vptUR As Point3d = New Point3d(12, vptUL.Y, 0)
            Dim vptLR As Point3d = New Point3d(vptUR.X, vptLL.Y, 0)
            Dim ptcoll As New Point3dCollection

            ptcoll.Add(vptLL)
            ptcoll.Add(vptLR)
            ptcoll.Add(vptUR)
            ptcoll.Add(vptUL)

            ' draw a rectangle on a no-plot layer ("defpoints") as a guide to the users for manual panel placement
            ' set "defpoints" layer current
            Dim acLyrTbl As LayerTable
            Dim acLyrTblRec As LayerTableRecord
            ' start transaction
            Using acTrans As Transaction = myDB2.TransactionManager.StartTransaction()
                acLyrTbl = acTrans.GetObject(myDB2.LayerTableId, OpenMode.ForRead)

                acLyrTblRec = acTrans.GetObject(acLyrTbl("0"), OpenMode.ForWrite)
                ' thaw layer
                acLyrTblRec.IsFrozen = False
                ' turn layer on
                acLyrTblRec.IsOff = False
                'make layer current
                myDB2.Clayer = acLyrTbl("0")

                '' Open the Block table record Model space for write
                Dim acBlkTbl As BlockTable
                Dim acBlkTblRec As BlockTableRecord

                acBlkTbl = acTrans.GetObject(myDB2.BlockTableId, OpenMode.ForRead)
                acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), OpenMode.ForWrite)

                ' draw the rectangle
                Dim rect As New DatabaseServices.Polyline2d(Poly2dType.SimplePoly, ptcoll, 0, True, 0, 0, Nothing)
                '' Add the new object to Model space and the transaction
                acBlkTblRec.AppendEntity(rect)
                acTrans.AddNewlyCreatedDBObject(rect, True)
                ' Commit the changes
                acTrans.Commit()
            End Using
            myDB2.SaveAs(dbPath, DwgVersion.Current)
        End Using&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 18 Dec 2010 14:32:25 GMT</pubDate>
    <dc:creator>jshimkus</dc:creator>
    <dc:date>2010-12-18T14:32:25Z</dc:date>
    <item>
      <title>How do I add objects to a drawing NOT open in Acad?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-do-i-add-objects-to-a-drawing-not-open-in-acad/m-p/2859146#M62635</link>
      <description>&lt;P&gt;I just want to open the drawings database and add objects to it then save and close the database.&lt;/P&gt;&lt;P&gt;The code I have is getting the drawings database, it appears to be commiting the objects, but the objects are not there when I open the drawing.&lt;/P&gt;&lt;P&gt;dbPath is a string path to an exisiting drawing file and I do&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;myDB.Dispose() the drawing database at the end of the code.&lt;/P&gt;&lt;P&gt;Is it even possible to add objects to a drawing without actually opening it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;            Using myDB As Database = New Database(False, False)
                myDB.ReadDwgFile(dbPath, FileOpenMode.OpenForReadAndWriteNoShare, True, "")
                Dim vptLL As Point3d = New Point3d(0, 0, 0)
                Dim vptUL As Point3d = New Point3d(vptLL.X, 12, 0)
                Dim vptUR As Point3d = New Point3d(12, vptUL.Y, 0)
                Dim vptLR As Point3d = New Point3d(vptUR.X, vptLL.Y, 0)
                Dim ptcoll As New Point3dCollection

                ptcoll.Add(vptLL)
                ptcoll.Add(vptLR)
                ptcoll.Add(vptUR)
                ptcoll.Add(vptUL)

                ' draw a rectangle on a no-plot layer ("defpoints") as a guide to the users for manual panel placement
                ' set "defpoints" layer current
                Dim acLyrTbl As LayerTable
                Dim acLyrTblRec As LayerTableRecord
                ' start transaction
                Using acTrans As Transaction = myDB.TransactionManager.StartTransaction()
                    acLyrTbl = acTrans.GetObject(myDB.LayerTableId, OpenMode.ForRead)

                    acLyrTblRec = acTrans.GetObject(acLyrTbl("0"), OpenMode.ForWrite)
                    ' thaw layer
                    acLyrTblRec.IsFrozen = False
                    ' turn layer on
                    acLyrTblRec.IsOff = False
                    'make layer current
                    myDB.Clayer = acLyrTbl("0")

                    '' Open the Block table record Model space for write
                    Dim acBlkTbl As BlockTable
                    Dim acBlkTblRec As BlockTableRecord

                    acBlkTbl = acTrans.GetObject(myDB.BlockTableId, OpenMode.ForRead)
                    acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), OpenMode.ForWrite)

                    Dim whoa As Integer
                    whoa = 1
                    Do Until whoa = 50
                        ' draw the rectangle
                        Dim rect As New DatabaseServices.Polyline2d(Poly2dType.SimplePoly, ptcoll, 0, True, 0, 0, Nothing)
                        '' Add the new object to Model space and the transaction
                        acBlkTblRec.AppendEntity(rect)
                        acTrans.AddNewlyCreatedDBObject(rect, True)
                        whoa = whoa + 1
                    Loop

                    ' Commit the changes
                    acTrans.Commit()
                End Using
            End Using&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Dec 2010 15:19:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-do-i-add-objects-to-a-drawing-not-open-in-acad/m-p/2859146#M62635</guid>
      <dc:creator>jshimkus</dc:creator>
      <dc:date>2010-12-17T15:19:21Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add objects to a drawing NOT open in Acad?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-do-i-add-objects-to-a-drawing-not-open-in-acad/m-p/2859248#M62636</link>
      <description>&lt;P&gt;It doesn't look like you save the database after you commit the changes.&amp;nbsp; Look at the SaveAs method.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Dec 2010 16:24:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-do-i-add-objects-to-a-drawing-not-open-in-acad/m-p/2859248#M62636</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-12-17T16:24:53Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add objects to a drawing NOT open in Acad?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-do-i-add-objects-to-a-drawing-not-open-in-acad/m-p/2859268#M62637</link>
      <description>&lt;P&gt;Thanks, when I would&amp;nbsp;try that the program would throw an access error on that line so I got rid of it.&lt;/P&gt;&lt;P&gt;I assume because there are lock files (dwl) for the drawing database I have open.&lt;/P&gt;&lt;P&gt;This is what I used...&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;myDB.SaveAs(dbPath, DwgVersion.Current)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Anything else?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Dec 2010 16:37:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-do-i-add-objects-to-a-drawing-not-open-in-acad/m-p/2859268#M62637</guid>
      <dc:creator>jshimkus</dc:creator>
      <dc:date>2010-12-17T16:37:10Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add objects to a drawing NOT open in Acad?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-do-i-add-objects-to-a-drawing-not-open-in-acad/m-p/2859946#M62638</link>
      <description>&lt;P&gt;I cleaned up the code and showed where I added the Savas&lt;/P&gt;&lt;P&gt;I get an "eFileSharingViolation" error when the program hits the myDB2.SaveAs line.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;        dbPath = "O:\projects\Test Location\Wallframingissue10\Views\View-Partition1.dwg"
        Using myDB2 As Database = New Database(False, False)
            myDB2.ReadDwgFile(dbPath, FileOpenMode.OpenForReadAndWriteNoShare, True, "")
            Dim vptLL As Point3d = New Point3d(0, 0, 0)
            Dim vptUL As Point3d = New Point3d(vptLL.X, 12, 0)
            Dim vptUR As Point3d = New Point3d(12, vptUL.Y, 0)
            Dim vptLR As Point3d = New Point3d(vptUR.X, vptLL.Y, 0)
            Dim ptcoll As New Point3dCollection

            ptcoll.Add(vptLL)
            ptcoll.Add(vptLR)
            ptcoll.Add(vptUR)
            ptcoll.Add(vptUL)

            ' draw a rectangle on a no-plot layer ("defpoints") as a guide to the users for manual panel placement
            ' set "defpoints" layer current
            Dim acLyrTbl As LayerTable
            Dim acLyrTblRec As LayerTableRecord
            ' start transaction
            Using acTrans As Transaction = myDB2.TransactionManager.StartTransaction()
                acLyrTbl = acTrans.GetObject(myDB2.LayerTableId, OpenMode.ForRead)

                acLyrTblRec = acTrans.GetObject(acLyrTbl("0"), OpenMode.ForWrite)
                ' thaw layer
                acLyrTblRec.IsFrozen = False
                ' turn layer on
                acLyrTblRec.IsOff = False
                'make layer current
                myDB2.Clayer = acLyrTbl("0")

                '' Open the Block table record Model space for write
                Dim acBlkTbl As BlockTable
                Dim acBlkTblRec As BlockTableRecord

                acBlkTbl = acTrans.GetObject(myDB2.BlockTableId, OpenMode.ForRead)
                acBlkTblRec = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace), OpenMode.ForWrite)

                ' draw the rectangle
                Dim rect As New DatabaseServices.Polyline2d(Poly2dType.SimplePoly, ptcoll, 0, True, 0, 0, Nothing)
                '' Add the new object to Model space and the transaction
                acBlkTblRec.AppendEntity(rect)
                acTrans.AddNewlyCreatedDBObject(rect, True)
                ' Commit the changes
                acTrans.Commit()
            End Using
            myDB2.SaveAs(dbPath, DwgVersion.Current)
        End Using&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 18 Dec 2010 14:32:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-do-i-add-objects-to-a-drawing-not-open-in-acad/m-p/2859946#M62638</guid>
      <dc:creator>jshimkus</dc:creator>
      <dc:date>2010-12-18T14:32:25Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add objects to a drawing NOT open in Acad?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-do-i-add-objects-to-a-drawing-not-open-in-acad/m-p/2860274#M62639</link>
      <description>&lt;P&gt;try&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;myDB2.ReadDwgFile(dbPath,&amp;nbsp;System.IO.&lt;SPAN style="color: #2b91af;"&gt;FileShare&lt;/SPAN&gt;.ReadWrite,&amp;nbsp;&lt;SPAN style="color: blue;"&gt;True&lt;/SPAN&gt;,&amp;nbsp;&lt;SPAN style="color: #a31515;"&gt;""&lt;/SPAN&gt;)&lt;BR /&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 20 Dec 2010 02:01:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-do-i-add-objects-to-a-drawing-not-open-in-acad/m-p/2860274#M62639</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-12-20T02:01:06Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add objects to a drawing NOT open in Acad?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-do-i-add-objects-to-a-drawing-not-open-in-acad/m-p/2860316#M62640</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;SPAN style="font-size: 12px;"&gt;------------------------------------------------------------------------------&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;STRONG&gt;&lt;EM&gt;'Is it even possible to add objects to a drawing without actually opening it?'&lt;/EM&gt;&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;------------------------------------------------------------------------------&lt;/DIV&gt;&lt;DIV&gt;Hi,&lt;/DIV&gt;&lt;DIV&gt;Without opening the drawing you want to do something?&lt;/DIV&gt;&lt;DIV&gt;Then have a look about ObjectDBX in this forum.&lt;/DIV&gt;&lt;DIV&gt;There is lot of interesting stuff about dbx.&lt;/DIV&gt;&lt;DIV&gt;Regards,&lt;/DIV&gt;&lt;DIV&gt;G&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Dec 2010 06:21:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-do-i-add-objects-to-a-drawing-not-open-in-acad/m-p/2860316#M62640</guid>
      <dc:creator>ProfWolfMan</dc:creator>
      <dc:date>2010-12-20T06:21:50Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add objects to a drawing NOT open in Acad?</title>
      <link>https://forums.autodesk.com/t5/net-forum/how-do-i-add-objects-to-a-drawing-not-open-in-acad/m-p/2860402#M62641</link>
      <description>&lt;P&gt;That got it!&lt;/P&gt;&lt;P&gt;Thanks Jeffrey.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Dec 2010 12:10:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/how-do-i-add-objects-to-a-drawing-not-open-in-acad/m-p/2860402#M62641</guid>
      <dc:creator>jshimkus</dc:creator>
      <dc:date>2010-12-20T12:10:50Z</dc:date>
    </item>
  </channel>
</rss>

