Showing results for 
Search instead for 
Do you mean 
Reply

NX bug in BlockStyler_DialogCreator ?

To all,

 

I made some cosmetic changes to a vb programe (adding comments, correcting spelling mistakes!) that sort to things. Since then the program crashes ~half way through with the error msg "Unhandled exception encountered in callback automation code". I am sure it's not related to my program but might to something to do with the GUI (UIbuilder)

 

I ran my "macro" and noticed the following in the syslog file

 

>>>> Error code  3520083 caught in file "D:\workdir\Reference\NX903_4\src\nxblockstyler\no\ind\BlockStyler_DialogCreator.cxx" at line number 1395
>>>> Error code  3520083 caught in file "D:\workdir\Patches\nx903_patch\src\uifw\no\ind\uifw_definitions.c" at line number 2301
>>>> Error code  3520083 caught in file "D:\workdir\Patches\nx903_patch\src\uifw\no\ind\uifw_definitions.c" at line number 2586
&MACRO FOCUS CHANGE IN 1
&MACRO MESSAGE_BOX -2, Unhandled exception encountered in callback automation code.

 

I get the same problem with the "released" macro which used to work just fine and the one I have modified.

 

Tested with  v9.0.3.4 & v10.0.2.6. Same problem

 

Q: Is it my programe or NX the issue?
   

Thanks

Regards

Production: NX9.0.3.4, NX10.0.2.6
Development: VB.NET (amateur level !)
10 REPLIES

Re: NX bug in BlockStyler_DialogCreator ?

Since the problem started after you made changes, that's the obvious place to start looking. Even though the changes were "cosmetic" you may have inadvertently added a special character, control character, etc. to some text string that is causing the issue. Sometimes these types of characters are not visible in a text editor.

 

Can you step through the program in the debugger and determine exactly what call is causing the exception and what the inputs to that function are?

Re: NX bug in BlockStyler_DialogCreator ?

[ Edited ]

That was my 1st thought too but so far nothing

 

I foung a copy of the program dated from August which works but the function where I think it might be failing appears to be identical.

 

Looks like a line by line check but I have just noticed that

previous version (which worked)

function 1: Dim theResultManager As CAE.ResultManager = theSession.ResultManager()

function 2: Dim resultManager As CAE.ResultManager = theSession.ResultManager

  

New version

function 1: Dim theResultManager As CAE.ResultManager = theSession.ResultManager()

function 2: Dim theresultManager As CAE.ResultManager = theSession.ResultManager

 

looks like I changed the name of the variable for name consistency

but it looks like I have also introduced the following: theResultManager.DeleteResult(theresults)

 

so I did a lot more than I thought!

Production: NX9.0.3.4, NX10.0.2.6
Development: VB.NET (amateur level !)

Re: NX bug in BlockStyler_DialogCreator ?

Are you using version control?  If yes and you make frequent commits, start stepping back in time to you can find hte commit that caused issues.

Re: NX bug in BlockStyler_DialogCreator ?

"but the function where I think it might be failing appears to be identical"

 

Sounds like you need to step through the code in a debugger so that you can know exactly where the problem occurs.

 

Other than that, as mentioned in my previous response, sometimes control characters that are not visble in all editors get into text files. The two functions may appear to be visually identical when they are really not. Try deleting the entire function from your current code, then copy the August version in and see if that helps.

Re: NX bug in BlockStyler_DialogCreator ?

not under full version control yet. Still in development

 

I am attemping to find where the code fails and narrow it down to a possible step where I am calling a function to process a CAE.Result. Rhater than callig the true function I created a test function which mimics a few lines of code

 

'main function
'..........................
Dim theresults As CAE.Result

theresults = SES_GetResultsRS(theActiveRSEvent)
					   
	If (theresults Is Nothing) Then
		theLW.WriteLine("-Unable to create Results Object for the RS Event - Processing results is ended and is skipped")
		GoTo ProcessNextCAEGroup:
	Else
		theLW.WriteLine("-Result OK")
		test(theresults)
	End if

	'rest of the sub ................

Function test(ByRef theInputResult As CAE.Result) As Boolean
					
	Dim theResultManagerTest As CAE.ResultManager = theSession.ResultManager

	if theResultManagerTest Is Nothing Then
		theLW.WriteLine("it's nothing")
		test=false
	Else
		theLW.WriteLine("it's Not nothing")
		test=true
	end if
	
	dim itemp as integer = theInputResult.AskNumLoadcases
	theLW.WriteLine(" AskNumLoadcases is: " & itemp.tostring)
		
	Dim lastLoadCase As CAE.BaseLoadcase
	lastLoadCase = theInputResult.getloadcases(theInputResult.AskNumLoadcases - 1)
	theLW.WriteLine(" Loadcase: " & lastLoadCase.Name)
			
End Function

 

the test fails straight after the If statement. TheInputResult is not nothing and it cannot get the number of load cases (.AskNumLoadcases). I do not know why the criptic error message is issued and this is truly the source of the error. in any case hte cod edoes not pass the If statement in the test function

 

any thing obvious to check or plain wrong ?

 

Thanks

Regards

Production: NX9.0.3.4, NX10.0.2.6
Development: VB.NET (amateur level !)

Re: NX bug in BlockStyler_DialogCreator ?

[ Edited ]

The "test" function either returns true or false within your IF block. After it returns a value, it stops processing (the rest of the function isn't executed). For your test function, you could move the "lastLoadCase" code before the IF block. That way it will be sure to execute.

 

Edit:

My apologies, ignore the above; I was under the impression that

{function name} = True

was equivalent to:

Return True

but this is not the case.

Re: NX bug in BlockStyler_DialogCreator ?


selex_ct wrote:

not under full version control yet. Still in development


That's the most important time to get it under version control ;-)

 

 

Ken Akerboom Sr CAx Systems Engr, Moog, Inc.
Production: NX10.0.3.5 MP5 + patch/TC11.2
I'd rather be e-steemed than e-diseaseled


Re: NX bug in BlockStyler_DialogCreator ?

test is only set to true or false in the if statement - there is nothing in there that forces a return. The itemp and lastLoadCase stuff is executed.

 

I wrote a wrapper around the test function and it works fine for me. It works either way, but I added a pair of () after GetLoadcases for clarity - the function does not take any arguments and the intent is to select the index of the array that is returned.

 

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF

Module Module1

    Dim theSession As Session = Session.GetSession()
    Dim theLw As ListingWindow = theSession.ListingWindow

    Dim theUI As UI = UI.GetUI()
    Dim theNxMessageBox As NXMessageBox = theUI.NXMessageBox

    Dim theUfSession As UFSession = UFSession.GetUFSession()

    Sub Main()

        theLw.Open()

        ' Get the current work part
        Dim basePart As BasePart = theSession.Parts.BaseWork

        ' Verify that it is a SIM part
        Dim simPart As CAE.SimPart = TryCast(basePart, CAE.SimPart)
        If simPart Is Nothing Then
            theNxMessageBox.Show("NX Result Access", NXMessageBox.DialogType.Error, _
                                 "The current work part is not a SIM part")
            Return
        End If

        ' Loop through all solutions in the SIM
        For Each solution As CAE.SimSolution In simPart.Simulation.Solutions.ToArray

            theLw.WriteLine("Solution: [" + solution.Name + _
                            "] Solver Type: [" + solution.SolverType + _
                            "] Solution Type: [" + solution.SolutionType + _
                            "] Analysis Type: [" + solution.AnalysisType + "]")

            ' Create a Result object for the current solution
            Dim resultManager As CAE.ResultManager = theSession.ResultManager
            Dim solResult As CAE.Result = resultManager.CreateSolutionResult(solution)

            test(solResult)

            theLw.WriteLine("")

        Next solution

    End Sub

    Function test(ByRef theInputResult As CAE.Result) As Boolean

        Dim theResultManagerTest As CAE.ResultManager = theSession.ResultManager

        If theResultManagerTest Is Nothing Then
            theLW.WriteLine("it's nothing")
            test = False
        Else
            theLW.WriteLine("it's Not nothing")
            test = True
        End If

        Dim itemp As Integer = theInputResult.AskNumLoadcases
        theLW.WriteLine(" AskNumLoadcases is: " & itemp.tostring)

        Dim lastLoadCase As CAE.BaseLoadcase
        lastLoadCase = theInputResult.GetLoadcases()(theInputResult.AskNumLoadcases - 1)
        theLW.WriteLine(" Loadcase: " & lastLoadCase.Name)

    End Function


    Public Function GetUnloadOption(ByVal dummy As String) As Integer

        'Unloads the image immediately after execution within NX
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

        '----Other unload options-------
        'Unloads the image when the NX session terminates
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination

        'Unloads the image explicitly, via an unload dialog
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly
        '-------------------------------

    End Function

End Module

 

Re: NX bug in BlockStyler_DialogCreator ?

just moved "lastLoadCase" code before the IF block and it still fails. I get into the function no problem. Assuming the issue is in that area is there a way of testing the variable 'theInputResult As CAE.Result' passed to the function?

Production: NX9.0.3.4, NX10.0.2.6
Development: VB.NET (amateur level !)