VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

autocad electric 2013 vba runtime error -214741811 (80010001)

11 REPLIES 11
Reply
Message 1 of 12
pierora
2358 Views, 11 Replies

autocad electric 2013 vba runtime error -214741811 (80010001)

Pls somebody can helps me with this issue ?

 

I got an automation error in a VBA routine thath manage the files (open a flile search with selectioset an objetc, modify, save and close for underd files).

 

Attached the routrine, for your info, but seems the error hang the routine in random point without a precise instruction.

 

Thank you

Private Function LineCount(FileName As String) As Long
i = 0
Open FileName For Input As #1
Do While Not EOF(1)
i = i + 1
Line Input #1, Dado
Loop
Close #1
MyLineCount = i
End Function


Sub CambiaNome()
MyPath = "D:\111111 - ZZZZ_New\ID11STD3604_rev1\"
Dim Ssnew As Object
Dim Entity As Object
Call LineCount(MyPath & "DWG_NEW.txt")
ReDim Preserve SourceDWG(MyLineCount)
ReDim Preserve DestinationDWG(MyLineCount)
MyDestinationPath = MyPath & "DWG_NEW.txt"

Open MyDestinationPath For Input As #1
X = 0
Do While Not EOF(1) ' Loop until end of file.
    Input #1, SourceDWG(X) ' Read data into two variables.
    Input #1, DestinationDWG(X) ' Read data into two variables.
    X = X + 1
Loop
Close #1


'IntGroupCode(0) = -4

'VarGroupValue(0) = "<OR"

IntGroupCode(0) = 0

VarGroupValue(0) = "INSERT"

IntGroupCode(1) = 2

VarGroupValue(1) = "NUMFG,NUMFGS"

'IntGroupCode(3) = 0

'VarGroupValue(3) = "TEXT"

'IntGroupCode(4) = 0

'VarGroupValue(4) = "MTEXT"

'IntGroupCode(5) = "-4"

'VarGroupValue(5) = "OR>"

'intGroupCode(0) = 0
'varGroupValue(0) = "INSERT"

'intGroupCode(1) = 2
'varGroupValue(1) = "NEW_SAIPEM"
Dim MyNewPath As String

For i = 0 To MyLineCount - 1
For Each Pippo In ThisDrawing.SelectionSets
    If Pippo.Name = "BOM1" Then
        ThisDrawing.SelectionSets("BOM1").Delete
        Exit For
    End If
Next
    If SourceDWG(i) <> "" Then
        MyNewPath = MyPath & SourceDWG(i)
        ThisDrawing.Application.Documents.Open (MyNewPath)
           
        ThisDrawing.SelectionSets.Add ("BOM1")
        Set Ssnew = ThisDrawing.SelectionSets("BOM1")

        Ssnew.Select acSelectionSetAll, , , IntGroupCode, VarGroupValue

    For Each Entity In Ssnew
        
        If TypeOf Entity Is AcadBlockReference Then
            
            Select Case Entity.Name
                
                Case "NUMFG"
                Numero = Entity.GetAttributes
                Numero(0).TextString = Str$(i) + 1
                
                Case "NUMFGS"
                Numero = Entity.GetAttributes
                If i = 56 Then
                    Numero(0).TextString = 56
                Else
                    Numero(0).TextString = Str$(i) + 2
                End If
                
            End Select
        End If
    Next
    End If
    MyDestinationPath = (MyPath & "NuoviNumeri\" & DestinationDWG(i))
    ThisDrawing.SaveAs (MyDestinationPath)

    ThisDrawing.Close
    Set Ssnew = Nothing
Next
End Sub

 

11 REPLIES 11
Message 2 of 12
Alfred.NESWADBA
in reply to: pierora

Hi,

 

>> but seems the error hang the routine in random point without a precise instruction

If you don't know where your routine crashes then:

  • start VBAIDE to get to the VBA-editor
  • from pulldown-menu "tools" start "options"
  • change to tab "General"
  • activate the option "Break in Class Module" (your current setting is one below I think)

If you have activated this option and your code runs into the exception the VBAIDE pops up and you see the code-line that makes troubles.

 

Good luck, - alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 3 of 12
pierora
in reply to: Alfred.NESWADBA

Thank you for your support, I already done the code debug option when it hangs, but everytime the error appears during the execution of a differents parts of the code.

 

Thank you

Message 4 of 12
Alfred.NESWADBA
in reply to: pierora

Hi,

 

Different exception-locations but same error message? ...strange ;(

 

Does your pc also crash with non-VBA-procedures, so just while working within AutoCAD? Because the "different" locations and same test-drawings + same VBA-code looks to me like memory-error (when it comes to a defect memory-position it crashes).

 

You could use the On Error Resume Next options and do a check like If Err.Number <> 0 after each line of your existing code so maybe you come more close then with breakpoints within the if's or you can use this to output any log-file.

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 5 of 12
Ed.Jobe
in reply to: Alfred.NESWADBA

If you are processing many files, you can't assume they all will have the same conditions. For example, you create a filtered selection set and then attempt to iterate it contents using For...Each. What if the selection set is empty? The next line will fail on If TypeOf Entity, because Entity will be null. You need to check the selectionset count for =0 before you try to iterate it or check that Entity is not null. There could be other differences in the files as well. If some of the dwgs are old, the block definitions could vary and the attributes could vary. One thing you could do is trap the error and log the filename of the dwg that had the problem.

 

Rather than using On Error Resume Next, use structured error handling. Here's my standard template.

Public Sub ImportPlotConfigs()
    On Error GoTo ErrHandler:
    
    'Do your work here.
    
    Exit Sub
    
ErrHandler:
    Select Case Err.Number
    'Add additional Case statements to meet your needs.
    Case 70, 75, -2147467259
        MsgBox Err.Number & " - " & Err.Description & vbCrLf & "File may be in use or read-only.", vbCritical, "Import Page Setups"
        GoTo GetFile
    Case Else
        MsgBox Err.Number & " - " & Err.Description, vbCritical, "ImportPlotConfigs"
    End Select
    
    
End Sub

 

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

Message 6 of 12
pierora
in reply to: Ed.Jobe

Thank you very much for your support, I'll try to modify the code as per your suggestions.

 

Concerning the selections set it cannot be empty due to alla files contain at leat two blocks NUMFG,NUMFGS which are the numebr of pages and the page of the drawings set 

 

I'll keep you update.

 

Thank you againg.

Message 7 of 12
pierora
in reply to: Ed.Jobe

Hi, 

I made modification you suggested to my code, but the problem it's always the same ! I got an automation error.

 

If I ask for a cdde debug and I excecute the code step by step with F8 function key I got any error.

 

Thank you for your support.

Message 8 of 12
Ed.Jobe
in reply to: pierora

I didn't say it would prevent errors. It just handles them. You can make it handle them better, though. At first, you will a dialog for all errors. When you get one, note what error number it is and add a Case statement for it. Then you can decide how to handle the error if it occurs. You could display a different message, or go back to a line label and take a different acction, or as I said before, log the error to a log file.

 

Your last reply did not supply any useful information for us to help you. You should also post your modified code.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

Message 9 of 12
Alfred.NESWADBA
in reply to: Ed.Jobe

Hi,

 

>> For example, you create a filtered selection set and then attempt to iterate it contents using For...Each.

>> What if the selection set is empty? The next line will fail on If TypeOf Entity, because Entity will be null

If the selectionset has 0 elements, then the For Each ... Next loop does not execute any statement within the For ... Next, so the line you mentioned (with TypeOf) will not be touched.

 

- alfred -

 

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 10 of 12
Ed.Jobe
in reply to: Alfred.NESWADBA

You're right. That looks dumb now that you point it out. I think I was confusing myself with something similar I ran into a couple of weeks ago, but the conditions were different. "dazed and confused" - LED Zepplin

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

Message 11 of 12
Alfred.NESWADBA
in reply to: Ed.Jobe

Hi,

 

I don't want to blame anyone here, my message was just for the OP that he does not try to search where there is nothing to look for. Sorry if you had another feeling with my post.

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 12 of 12
Ed.Jobe
in reply to: Alfred.NESWADBA

No problem, I'm fine. Thanks for catching my mistake.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost