Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Error closing dwg files

  1. #1
    100 Club amaser's Avatar
    Join Date
    2006-05
    Location
    Joliet, IL
    Posts
    105
    Login to Give a bone
    0

    Default Error closing dwg files

    I've got a .NET dll that checks for the name of the open dwg, and, based on that name, it automatically exports to v2007 (file version). This is done to support users who use earlier versions.

    most dwgs work fine, if the dwg name doesn't meet the criteria, it just closes,
    if it does meet the criteria, it saves the earlier version and then closes.

    but i've got a couple of drawings that error before close, and the earlier version file is corrupt.
    it does make the file, but it's unusual. I've tried purging, the audit command, and everything else i can think of, can't figure out why only a few drawings error out. It's always the same few dwg files, so I don't think it's a timing thing. I have 3 files where this doesn't work, so far everything else does.

    the error is: INTERNAL ERROR: !dbobji.cpp@7319: eNotOpenForWrite.

    I've attached my .NET code here

    Any ideas?
    Attached Files Attached Files

  2. #2
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,419
    Login to Give a bone
    0

    Default Re: Error closing dwg files

    Have you tried to manually do a Saveas and see if it still gets corrupted?
    C:> ED WORKING....


    LinkedIn

  3. #3
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: Error closing dwg files

    Attached archive is corrupted
    Can you show us your code as plain text or attach it as a text file here

  4. #4
    100 Club amaser's Avatar
    Join Date
    2006-05
    Location
    Joliet, IL
    Posts
    105
    Login to Give a bone
    0

    Default Re: Error closing dwg files

    I can export the dwg by hand. So far, for these few dwgs that don't work, that's what I've been doing. But it's an administration hassle to have to do certain files by hand, and have the rest work fine.

    In addition, I've attached my code as a text file here, per request, but I don't think that it's relevant to the problem, since most files work fine. but just in case, I'm putting in here.
    Attached Files Attached Files

  5. #5
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: Error closing dwg files

    Quote Originally Posted by amaser View Post
    I can export the dwg by hand. So far, for these few dwgs that don't work, that's what I've been doing. But it's an administration hassle to have to do certain files by hand, and have the rest work fine.

    In addition, I've attached my code as a text file here, per request, but I don't think that it's relevant to the problem, since most files work fine. but just in case, I'm putting in here.
    Sorry it's not a solution of your problem
    Just a hint
    You have to use VB.NET way to work with files
    Add System.IO namespace and play with this code snip:
    Code:
     
     Imports System.IO
    ''rest your code here
                'set final path
                'strPath = strPath & "\dwg\XREF_BASE_" & projNum & ".dwg"
                strPath = Path.Combine(strPath & "\dwg\XREF_BASE_", projNum & ".dwg")
                Dim folder As String = Path.GetDirectoryName(strPath)
                Dim filename As String = Path.GetFileName(strPath)
                Dim ex As String = Path.GetExtension(strPath)
                MsgBox("Full Name: " & strPath)
                MsgBox("Folder: " & folder)
                MsgBox("Short Name: " & filename)
                MsgBox("Extension: " & ex)
    I'll be back to this topic later

    ~'J'~

  6. #6
    100 Club amaser's Avatar
    Join Date
    2006-05
    Location
    Joliet, IL
    Posts
    105
    Login to Give a bone
    0

    Default Re: Error closing dwg files

    Thanx, I'll try to play with that for a bit.

    But than why would my code work perfectly for a lot of things, but not some particular files?

  7. #7
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: Error closing dwg files

    Quote Originally Posted by amaser View Post
    Thanx, I'll try to play with that for a bit.

    But than why would my code work perfectly for a lot of things, but not some particular files?
    Try this Q&D code example for the quick test
    then rewrite it to you needs:
    Code:
     
    Imports Autodesk.AutoCAD.Runtime
    Imports Autodesk.AutoCAD.ApplicationServices
    Imports Autodesk.AutoCAD.DatabaseServices
    Imports Microsoft.Win32
    Imports System.Diagnostics
    Imports System.IO
    Imports Autodesk.AutoCAD.EditorInput
    Namespace Augi
        Public Class ExportVersion
            Implements Autodesk.AutoCAD.Runtime.IExtensionApplication
            'declare variables as private if you need to declare as public
            'then realize an accesss to variables using 'get' and 'set' properties
            Private dm As DocumentCollection
            Private doc As Document
            Private db As Database
            Private ed As Editor
            Const m_Path As String = "c:\"
            Private strPath As String
            ''' <summary>
            ''' initialize members
            ''' </summary>
            Private Sub MyInitialize()
                dm = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager
                doc = dm.MdiActiveDocument
                db = doc.Database
                ed = doc.Editor
                strPath = ""
            End Sub
            ''' <summary>
            ''' method will start on loading
            ''' </summary>
            Public Sub Initialize() Implements Autodesk.AutoCAD.Runtime.IExtensionApplication.Initialize
                'initialize variables
                Try
                    If dm Is Nothing Then
                        MyInitialize()
                    End If
                    ed.WriteMessage(vbLf & "Reactor loader started...")
                    '' here your code to build the path
                    '' I use dummy path for test ony
                    strPath = Path.Combine(m_Path, "Test\Boo")
                    strPath = Path.Combine(strPath, "bla_bla.dwg")
                    ed.WriteMessage(vbLf & "Possible Full Path: {0}", strPath)
                    ''events register here: 
                    'use simplified syntax to register events
                    AddHandler doc.BeginDocumentClose, AddressOf OnClosingDocument
                Catch ex As Autodesk.AutoCAD.Runtime.Exception
                    ed.WriteMessage(vbLf & ex.Message & vbLf & ex.StackTrace)
                Finally
                End Try
                ed.WriteMessage(vbLf & "Reactor loader ended..")
            End Sub
            ''' <summary>
            ''' methods will start on closing document
            ''' </summary>
            ''' <remarks></remarks>
            Public Sub Terminate() Implements Autodesk.AutoCAD.Runtime.IExtensionApplication.Terminate
                Try
                    RemoveHandler doc.BeginDocumentClose, AddressOf OnClosingDocument
                Catch
                End Try
            End Sub
            Private Sub OnClosingDocument(ByVal sender As Object, ByVal e As Autodesk.AutoCAD.ApplicationServices.DocumentBeginCloseEventArgs)
                Try
                    MsgBox(strPath)
                    db.SaveAs(strPath, False, DwgVersion.AC1021, db.SecurityParameters)
                Catch ex As System.Exception
                Finally
     
                End Try
            End Sub
     
        End Class
    End Namespace

  8. #8
    100 Club amaser's Avatar
    Join Date
    2006-05
    Location
    Joliet, IL
    Posts
    105
    Login to Give a bone
    0

    Default Re: Error closing dwg files

    I have tried your Q&D code, but nothing happens.
    it successfully compiles, and the dll loads fine at startup,
    but when i close a dwg, nothing happens, no msgboxes, no files in your dummy path (c:\test\Boo\blah_blah.dwg)
    no nothing. is there some special way to start running the code?

  9. #9
    100 Club amaser's Avatar
    Join Date
    2006-05
    Location
    Joliet, IL
    Posts
    105
    Login to Give a bone
    0

    Default Re: Error closing dwg files

    okay, i get the message box that shows title="Export Version" mesaage="c"\test\boo\blah_blah.dwg", but only when it closes "Drawing1.dwg" after first loading civil3d. if i have no dwg files open, and then open/create a new 1, nothing happens. or if i open one of my drawings, and close it nothing happens.

    also, the file is never actually created. just the messsage box with the path shows up.

    I need the code to check each drawing that closes, and if it's one of ours, with our naming convention, save it to the earlier version, otherwise just close it without exporting.

  10. #10
    AUGI Addict fixo's Avatar
    Join Date
    2005-05
    Location
    Pietari, Venäjä
    Posts
    1,269
    Login to Give a bone
    0

    Default Re: Error closing dwg files

    Quote Originally Posted by amaser View Post
    I have tried your Q&D code, but nothing happens.
    it successfully compiles, and the dll loads fine at startup,
    but when i close a dwg, nothing happens, no msgboxes, no files in your dummy path (c:\test\Boo\blah_blah.dwg)
    no nothing. is there some special way to start running the code?
    Keep in mind you have to check if this peth exist before of run this code
    Don't remember the synax, probably something like from the top of my had:
    Code:
    if Path.Exist("your foldername here") then ...
    Just create a dummy folder for testing the code before then remove it after
    I think that is a reason - the folder does not exist
    Sorry I havent have a time now,
    ask me for more tomorrow

Page 1 of 2 12 LastLast

Similar Threads

  1. 2008: Publish error: Error closing document
    By LanceMcHatton in forum AutoCAD Plotting
    Replies: 1
    Last Post: 2013-07-16, 09:14 AM
  2. Error after closing Revit 2009
    By patricks in forum Revit Architecture - General
    Replies: 27
    Last Post: 2009-08-28, 01:14 PM
  3. Error on closing Autocad
    By aquaman in forum VBA/COM Interop
    Replies: 1
    Last Post: 2009-01-29, 11:31 AM
  4. Closing Autocad fatal error
    By jjacoby in forum AutoCAD General
    Replies: 4
    Last Post: 2005-06-11, 09:02 PM
  5. runtime error ...after closing acad
    By ironwood1957 in forum VBA/COM Interop
    Replies: 0
    Last Post: 2005-03-04, 10:22 PM

Posting Permissions

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