Results 1 to 3 of 3

Thread: Editing CAD Files in a Loop

  1. #1
    Member
    Join Date
    2009-07
    Posts
    2
    Login to Give a bone
    0

    Default Editing CAD Files in a Loop

    Hello,

    I want to edit some CAD Files in a Loop. I am opening the files with the following .net-command:

    Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Open(sCADFiles[i],false);

    When I try to edit the opened files I get an elockviolation Error!

    When I try to read readonly flag it is set to false!

    Anybody an Idea?

    Kind Regards

    Karl-Heinz

  2. #2
    Woo! Hoo! my 1st post
    Join Date
    2007-01
    Posts
    1
    Login to Give a bone
    0

    Default Re: Editing CAD Files in a Loop

    This is a C# routine that I use to open all of the files in a folder.

    Code:
    // Application Session Command with localized name
            [CommandMethod("CommandGroup", "CommandName", "LocalCommandName", CommandFlags.Modal | CommandFlags.Session)]
            public void ExportDWG()
            {
                string strPath = "";
    
                strPath = BrowseFolder();  //Routine that shows dialog and returns path to a folder
                // Process the list of files found in the directory.
                string[] fileEntries = Directory.GetFiles(strPath, "*.dwg");
                foreach (string strFileName in fileEntries)
                {
                    //Only Process Files that end with .DWG
                    if (strFileName.EndsWith(".DWG", StringComparison.OrdinalIgnoreCase))
                    {
                        Database acadDB = new Database(); 
                        //Open Drawing File
                        acadDB.ReadDwgFile(strFileName, FileShare.ReadWrite, true, "");
                        Transaction acadtrans = acadDB.TransactionManager.StartTransaction();
                        try
                        {
                            // Place Code Here
                            acadtrans.Commit();
                        }
                        catch (Autodesk.AutoCAD.Runtime.Exception)
                        {
                            acadtrans.Abort();
                        }
                        finally
                        {
                            acadtrans.Dispose();
                            acadDB.Dispose();
                        }
                    }
    
                }
                
            }
    Last edited by RobertB; 2009-07-16 at 05:16 PM. Reason: Added [code] tags

  3. #3
    Active Member
    Join Date
    2007-04
    Posts
    81
    Login to Give a bone
    0

    Default Re: Editing CAD Files in a Loop

    One of the key items in the code shown is that the CommandFlags.Session attribute is set to session.

    Just thought i would point that out


    Patrick K Johnson
    http:\\www.cadenhancement.com

Similar Threads

  1. editing the ACTM files
    By FYRBRY in forum AutoCAD Action Recorder
    Replies: 2
    Last Post: 2013-04-10, 06:44 PM
  2. Save command creates "Done" loop in certain DWG files
    By Chris.N in forum AutoCAD General
    Replies: 2
    Last Post: 2007-01-24, 10:38 PM
  3. editing ARX files
    By mpemberton in forum ARX
    Replies: 2
    Last Post: 2005-07-27, 08:11 AM
  4. Block Insert Array (Loop within a Loop)
    By wpeacock in forum VBA/COM Interop
    Replies: 2
    Last Post: 2005-06-14, 04:24 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •