Results 1 to 2 of 2

Thread: Error on closing Autocad

  1. #1
    Member
    Join Date
    2008-09
    Posts
    6
    Login to Give a bone
    0

    Default Error on closing Autocad

    Hey!

    I have a problem with MEP08. When running the following code, autocad reports errors after CLOSING the app.


    Sub Get_BoxToBox_Table3()
    Dim ModelSpace As AcadModelSpace
    Dim Item As Variant

    Set ModelSpace = ThisDrawing.ModelSpace

    For Each Item In ModelSpace
    If (Item.ObjectName = "AecbDbWire") Then
    Dim Conn As AecbConnector
    For Each Conn In Item.Connectors
    Dim ConnMembers As Variant
    ConnMembers = Conn.ConnectedMembers
    ConnMembers = Empty
    Next
    Set Conn = Nothing
    End If
    Next
    Item = Empty
    Set ModelSpace = Nothing
    End Sub

    The errors are:
    http://aquaman.planet.ee/Stuhv/Forum...ror/Err1.jpg?2
    http://aquaman.planet.ee/Stuhv/Forum...ror/Err2.jpg?2

    And :

    INTERNAL ERROR: Attempt to access AecScheduleDataServices after shutdown!

    If I remove the line ConnMembers = Conn.ConnectedMembers, everything is ok. The real macro works like it should, so no problem there. It seems, that some resource has been left unreleased, and when trying to release, it seems that system took already care of it.
    I have tried to declare all variables, but no use.

    Any ideas?

    Regards,
    Aq

  2. #2
    Active Member
    Join Date
    2007-12
    Posts
    68
    Login to Give a bone
    0

    Default Re: Error on closing Autocad

    Quote Originally Posted by aquaman View Post
    Hey!

    I have a problem with MEP08. When running the following code, autocad reports errors after CLOSING the app.


    Sub Get_BoxToBox_Table3()
    Dim ModelSpace As AcadModelSpace
    Dim Item As Variant

    Set ModelSpace = ThisDrawing.ModelSpace

    For Each Item In ModelSpace
    If (Item.ObjectName = "AecbDbWire") Then
    Dim Conn As AecbConnector
    For Each Conn In Item.Connectors
    Dim ConnMembers As Variant
    ConnMembers = Conn.ConnectedMembers
    ConnMembers = Empty
    Next
    Set Conn = Nothing
    End If
    Next
    Item = Empty
    Set ModelSpace = Nothing
    End Sub

    The errors are:
    http://aquaman.planet.ee/Stuhv/Forum...ror/Err1.jpg?2
    http://aquaman.planet.ee/Stuhv/Forum...ror/Err2.jpg?2

    And :

    INTERNAL ERROR: Attempt to access AecScheduleDataServices after shutdown!

    If I remove the line ConnMembers = Conn.ConnectedMembers, everything is ok. The real macro works like it should, so no problem there. It seems, that some resource has been left unreleased, and when trying to release, it seems that system took already care of it.
    I have tried to declare all variables, but no use.

    Any ideas?

    Regards,
    Aq
    Part of the trouble you'll have, getting no responses, is that a lot of us dont have that app running under acad, and therefore cannot test it. Theres not much that we can do about that, myself included. But I would try some basic code formatting first, and then maybe you can make your bug pop up in a different place?

    First, "Dim ModelSpace As AcadModelSpace"
    Id rename it, VBA lets you redefine existing object names, and using variable names for yourself, using the same names can only cause you grief if it happens.

    "Dim Item As Variant"
    again, a reserved word, try something like ConnItem


    "Dim Conn As AecbConnector"
    "Dim ConnMembers As Variant"

    - id move ALL dim statements to the top of the code, and out of your loop. *Any* code that can be taken out of a loop, should be.

    "ConnMembers = Empty" Im not sure what this does - it looks like you are just trying to "clean up' variables. if you wish to keep this, move it past the end of your loop, atb the end of your code.

    "Set Conn = Nothing" This may give a hint as to your troubles. basically, the only variables you really GOTTA clean up, are object variables - the ones that use "SET" to assign them to a variable. But I dont know if "Conn" is an object variable - because you never SET conn to anything in the code , before you set it to NOTHING. Firstly, id set conn to NOTHING at the very end of your sub, outside the loop. Secondly, id try using SET on your Conn variable in the loop, to see if that errors out. if it does error out, then it is not an object variable. if it takes the SET statement, then it IS an object variable.

    Does "Item.Connectors" have a COUNT property? try some code like the following:
    (typed on the fly....)


    Dim NumConnectors as long, I as long
    NumConnectors = Item.Connectors.Count

    if NumConnectors > 0 then
    For I=0 to NumConnectors
    Set Conn = ConnItem.Connectors.Item(I)
    next i
    end if


    But again, none of this will work unless you rename your variables, explicitly assign them to definite types, and then you can start getting definite errors. I cant even tell you if the types are correct - because, again, I dont have AEC.

    But tightening up the programming code, and maybe rewriting the code differently, may allow your bug to pop up in a more reconizable place.

    Good luck.

Similar Threads

  1. 2012: Emptye error or warning when closing AutoCAD
    By info.48157 in forum AutoCAD General
    Replies: 3
    Last Post: 2014-03-12, 03:34 PM
  2. 2008: Publish error: Error closing document
    By LanceMcHatton in forum AutoCAD Plotting
    Replies: 1
    Last Post: 2013-07-16, 09:14 AM
  3. Replies: 8
    Last Post: 2007-06-04, 07:01 PM
  4. Closing AutoCAD with project opens causes fatal error
    By bn.srinivasarao in forum VBA/COM Interop
    Replies: 1
    Last Post: 2006-02-21, 04:26 PM
  5. Closing Autocad fatal error
    By jjacoby in forum AutoCAD General
    Replies: 4
    Last Post: 2005-06-11, 09:02 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
  •