<?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: Open and Edit several documents in AutoCAD in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/open-and-edit-several-documents-in-autocad/m-p/5541524#M41154</link>
    <description>Hi! Thanks for your answer.&lt;BR /&gt;I got one way to open every Doc and edit them but my problem now is try to save and close.....&lt;BR /&gt;&lt;BR /&gt;About to open just the database I Don't understand because to edit a document I Have to open it, right? And the code that I created works into the active document. Please could you explain it to me little more about it.&lt;BR /&gt;&lt;BR /&gt;Thanks in advance</description>
    <pubDate>Sun, 15 Mar 2015 13:30:33 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2015-03-15T13:30:33Z</dc:date>
    <item>
      <title>Open and Edit several documents in AutoCAD</title>
      <link>https://forums.autodesk.com/t5/net-forum/open-and-edit-several-documents-in-autocad/m-p/5530853#M41152</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;I created a code that allow me to add and edit elements(entities) in AutoCAD, but it's just for a document active, and I would like to do it for several documents, I mean that my code could work into all of them&lt;/P&gt;&lt;P&gt;This is the code that I tried to do, and I know that i should do something else because it works for the document and stop.&lt;/P&gt;&lt;P&gt;Public Class ClsOpenEditDocumentsDWG&lt;BR /&gt;&amp;lt;CommandMethod("OpenEditDWG", CommandFlags.Session)&amp;gt;&lt;BR /&gt;Public Shared Sub &lt;SPAN&gt;OpenEdit&lt;/SPAN&gt;DWG()&lt;BR /&gt;Dim Path&amp;nbsp;As String = "C:\Users\ladrian\Desktop\CAD'S IDIADA\Revit_CAD"&lt;BR /&gt;Dim FilesX&amp;nbsp;As String()&lt;BR /&gt;If Directory.Exists(Path) = True Then&lt;BR /&gt;&amp;nbsp;&lt;SPAN&gt;FilesX&amp;nbsp;&lt;/SPAN&gt;= Directory.GetFiles(Path, "*.dwg", SearchOption.AllDirectories)&lt;BR /&gt;For File&amp;nbsp;Archivo As String In&amp;nbsp;&lt;SPAN&gt;FilesX&lt;/SPAN&gt;&lt;BR /&gt;Try&lt;BR /&gt;Dim AcDocMng As DocumentCollection = Application.DocumentManager&lt;BR /&gt;DocumentCollectionExtension.Open(AcDocMng, File, False)&lt;/P&gt;&lt;P&gt;Catch ex As Exception&lt;BR /&gt;'here the error&lt;BR /&gt;End Try&lt;/P&gt;&lt;P&gt;Next&lt;/P&gt;&lt;P&gt;End If&lt;BR /&gt;Dim Docs As DocumentCollection = Application.DocumentManager&lt;BR /&gt;For Each Doc As Document In Docs&lt;BR /&gt;Application.DocumentManager.MdiActiveDocument = Doc&lt;BR /&gt;Try&lt;BR /&gt;EditEntities() 'Here it is my routine that process the information in a single document&lt;BR /&gt;Catch ex As Exception&lt;BR /&gt;MsgBox(Doc.Name)&lt;BR /&gt;End Try&lt;BR /&gt;'Application.DocumentManager.DocumentActivationEnabled = False&lt;BR /&gt;'DocumentExtension.CloseAndSave(Doc, Doc.Name)&lt;BR /&gt;Next&lt;/P&gt;&lt;P&gt;End Sub&lt;BR /&gt;End Class&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So as I said, it just work to the first document... and stop...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'll appreciate any help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;Luis Ibañez&lt;/P&gt;</description>
      <pubDate>Fri, 06 Mar 2015 11:15:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/open-and-edit-several-documents-in-autocad/m-p/5530853#M41152</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-03-06T11:15:01Z</dc:date>
    </item>
    <item>
      <title>Re: Open and Edit several documents in AutoCAD</title>
      <link>https://forums.autodesk.com/t5/net-forum/open-and-edit-several-documents-in-autocad/m-p/5534347#M41153</link>
      <description>do you start from a not saved Drawing1 ?&lt;BR /&gt;AutoCAD might close the unused Drawing1 when opening the first (other) drawing. Then after manipulating that drawing and closing there is no docume nt anymore which might cause some problems.&lt;BR /&gt;&lt;BR /&gt;Do you really need to open the drawing as a document ? You might consider to open just the Database and then&lt;BR /&gt;EditEntities(inThatDb)&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 10 Mar 2015 08:32:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/open-and-edit-several-documents-in-autocad/m-p/5534347#M41153</guid>
      <dc:creator>SENL1362</dc:creator>
      <dc:date>2015-03-10T08:32:59Z</dc:date>
    </item>
    <item>
      <title>Re: Open and Edit several documents in AutoCAD</title>
      <link>https://forums.autodesk.com/t5/net-forum/open-and-edit-several-documents-in-autocad/m-p/5541524#M41154</link>
      <description>Hi! Thanks for your answer.&lt;BR /&gt;I got one way to open every Doc and edit them but my problem now is try to save and close.....&lt;BR /&gt;&lt;BR /&gt;About to open just the database I Don't understand because to edit a document I Have to open it, right? And the code that I created works into the active document. Please could you explain it to me little more about it.&lt;BR /&gt;&lt;BR /&gt;Thanks in advance</description>
      <pubDate>Sun, 15 Mar 2015 13:30:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/open-and-edit-several-documents-in-autocad/m-p/5541524#M41154</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-03-15T13:30:33Z</dc:date>
    </item>
    <item>
      <title>Re: Open and Edit several documents in AutoCAD</title>
      <link>https://forums.autodesk.com/t5/net-forum/open-and-edit-several-documents-in-autocad/m-p/5542126#M41155</link>
      <description>Hi, 
You need to add all the documents to the collection and iterate through the loop, get the document and do your process and save as and close the document.

What are problem are you facing, can I check through your code ? I can help you if you are missing something.
Do let me know.</description>
      <pubDate>Mon, 16 Mar 2015 06:31:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/open-and-edit-several-documents-in-autocad/m-p/5542126#M41155</guid>
      <dc:creator>moogalm</dc:creator>
      <dc:date>2015-03-16T06:31:35Z</dc:date>
    </item>
    <item>
      <title>Re: Open and Edit several documents in AutoCAD</title>
      <link>https://forums.autodesk.com/t5/net-forum/open-and-edit-several-documents-in-autocad/m-p/5542142#M41156</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This example shows how to open the Database but &lt;STRONG&gt;not&lt;/STRONG&gt; load it as a document in the AutoCAD Editor only, and then manipulate the Entities.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;        [CommandMethod("TestOpenDb")]
        public void TestOpenDb()
        {
            Document doc = AcadApp.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;

            string dwgPathname = @"c:\temp\x.dwg";
            try
            {
                if (!File.Exists(dwgPathname))
                    throw new System.Exception(string.Format("File not found: {0}", dwgPathname));

                 using (Database dwgDb = new Database(false, true))
                {
                     //Open Database but not "visible" in AutoCAD Editor
                    dwgDb.ReadDwgFile(dwgPathname, FileShare.Read, true, null);
                    dwgDb.CloseInput(true);
                    EditEntities(dwgDb);
                    dwgDb.Save();

                }

            }
            catch (System.Exception ex)
            {
                ed.WriteMessage(ex.Message);
            }

        }

        public bool EditEntities(Database db)
        {

            using (Transaction tr=db.TransactionManager.StartTransaction())
            {
                // 'Here it is my routine that process the information in a single document
                tr.Commit();
            }
            return true;
        }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 16 Mar 2015 06:59:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/open-and-edit-several-documents-in-autocad/m-p/5542142#M41156</guid>
      <dc:creator>SENL1362</dc:creator>
      <dc:date>2015-03-16T06:59:20Z</dc:date>
    </item>
    <item>
      <title>Re: Open and Edit several documents in AutoCAD</title>
      <link>https://forums.autodesk.com/t5/net-forum/open-and-edit-several-documents-in-autocad/m-p/5549341#M41157</link>
      <description>&lt;P&gt;Thanks for all help Guys!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;At the end, becuase there were serveral problem to save de database I used this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2" face="Consolas"&gt;DWGDB.SaveAs(DWGDB.Name, &lt;/FONT&gt;&lt;FONT color="#2b91af" face="Consolas" size="2"&gt;DwgVersion&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;.Current, &lt;/FONT&gt;&lt;FONT color="#2b91af" face="Consolas" size="2"&gt;DwgVersion&lt;/FONT&gt;&lt;FONT face="Consolas" size="2"&gt;.Current, DWGDB.SecurityParameters)&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Mar 2015 21:11:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/open-and-edit-several-documents-in-autocad/m-p/5549341#M41157</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-03-19T21:11:37Z</dc:date>
    </item>
  </channel>
</rss>

