Shane0000 Posted August 6, 2008 Share Posted August 6, 2008 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 More sharing options...
ChrisL Posted August 6, 2008 Share Posted August 6, 2008 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 [u]Scripts[/u]Minimize gui to systray _ Fail safe source recoveryMsgbox UDF _ _procwatch() Stop your app from being closedLicensed/Trial software system _ Buffering Hotkeys_SQL.au3 ADODB.Connection _ Search 2d Arrays_SplashTextWithGraphicOn() _ Adjust Screen GammaTransparent Controls _ Eventlogs without the crap_GuiCtrlCreateFlash() _ Simple Interscript communication[u]Websites[/u]Curious Campers VW Hightops Lambert Plant Hire Link to comment Share on other sites More sharing options...
Shane0000 Posted August 6, 2008 Author Share Posted August 6, 2008 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now