Jump to content

AutoIt Crashes [VB]


Recommended Posts

I am using the below code to get an array of attributes and during execution autoit crashes. The crash happens at line '$aAttributes = $oSiteInfo.getAttributes'

The method '.getAttributes' returns an array

Any one know what might be causing the crashing ?

Big thanks for any help.

Shane

$oModelSpace = $oAcadActDoc.modelspace
    For $i = 1 TO $oModelSpace.COUNT - 1
        iF $oModelSpace.ITEM($I).objectname = "AcDbBlockReference" Then
            If $oModelSpace.ITEM($I).name = "SiteInfo" and $oModelSpace.ITEM($I).hasAttributes Then
                $oSiteInfo = $oModelSpace.ITEM($I)
                $aAttributes = $oSiteInfo.getAttributes
                ExitLoop 
            EndIf   
        EndIf
    Next
Link to comment
Share on other sites

Add a COM error handler to get more info and avoid crashes

$oMyError = ObjEvent("AutoIt.Error","MyErrFunc"); Install a custom error handler




    $oModelSpace = $oAcadActDoc.modelspace
    For $i = 1 TO $oModelSpace.COUNT - 1
        iF $oModelSpace.ITEM($I).objectname = "AcDbBlockReference" Then
            If $oModelSpace.ITEM($I).name = "SiteInfo" and $oModelSpace.ITEM($I).hasAttributes Then
                $oSiteInfo = $oModelSpace.ITEM($I)
                $aAttributes = $oSiteInfo.getAttributes
                ExitLoop 
            EndIf   
        EndIf
    Next



Func MyErrFunc() 
   $HexNumber=hex($oMyError.number,8) 
   Msgbox(0,"","We intercepted a COM Error !" & @CRLF & _
                "Number is: " & $HexNumber & @CRLF & _
                "Windescription is: " & $oMyError.windescription ) 

   $g_eventerror = 1; something to check for when this function returns 
Endfunc
Link to comment
Share on other sites

Thanks, I had not done one of those yet.

However, The problem remains and the error handler does not show anything before autoit3.exe crashes.

{The handler does work, tested with bogus vb methods }

Could it be that autoit doesnt like the return value of '$aAttributes = $oSiteInfo.getAttributes'

This should work, other methods used on the object return fine ... ?

RetVal = object.GetAttributes() 

Object

BlockRef, ExternalReference, MInsertBlock
The object or objects this method applies to. 

RetVal

Variant (array of AttributeReference objects)
The array of AttributeReference objects. 

Remarks 

This method returns an array of editable attribute references attached to the block reference.

Add a COM error handler to get more info and avoid crashes

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...