cancel
Showing results for 
Search instead for 
Did you mean: 

Get value from UIBlock.IntegerBlock?

Phenom
Phenom

To all

 

A bit a "stupid" question! I have some code which takes data from a UI interface (UI block)

Programme works as intended but I have just added another input block in the UI which takes an integer (1 to 10)  and the code stopped working. It seems that it fails because of the line

 

iTopNValue = Blk101iTopNValue.GetProperties.GetInteger("Value")

 

where the code reads the input data N.

As I have been testing with a default value of N=1 I have never had any problem

I have defined the variable as

 

Public Shared iTopNValue As Integer

 

 

 

 

Any suggestions?

 

Thansk

Regards

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

Re: Get value from UIBlock.IntegerBlock?

Siemens Phenom Siemens Phenom
Siemens Phenom

What is the error message that it fails with?

Re: Get value from UIBlock.IntegerBlock?

Phenom
Phenom

'Unhandled exception encountered in callback automation code'

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

Re: Get value from UIBlock.IntegerBlock?

Siemens Phenom Siemens Phenom
Siemens Phenom

Can you look in the syslog for the exact exception wording, or enclose the GetInteger statement in a Try/Catch block to catch the exception and print it to the listing window?

Re: Get value from UIBlock.IntegerBlock?

Siemens Phenom Siemens Phenom
Siemens Phenom
A couple of comments about your code, which are not directly related to your question: (1) The way you are using GetProperties will lead to a (small) memory leak. You are not assigning the PropertyList to a variable, so you have no way to Dsipose it. (2) I would recommend not using the PropetryList thing at all. Code is far easier to write if you use the properties of the IntegerBlock. So, Blk101iTopNValue.Value will give you the number you want.
山田
yamada

Re: Get value from UIBlock.IntegerBlock?

Phenom
Phenom

from the syslog

 

&MACRO FOCUS CHANGE IN 1

&MACRO MESSAGE_BOX -2, Unhandled exception encountered in callback automation code.

&MACRO ASK_ITEM 8192002 (1 BOOL 0) = 1 ! Preview

&MACRO ASK_ITEM 327680 (1 INTE 0) = 1 ! Top 'N' value to report N =

&MACRO ASK_ITEM 327680 (1 INTE 0) = 1 ! Top 'N' value to report N =

&MACRO ASK_ITEM 3211264 (1 SCAL 0) = 0.0000000000000000 !

&MACRO ASK_ITEM 3211264 (1 SCAL 0) = 0.0000000000000000 !

&MACRO ASK_ITEM 5439488 (1 STRN 0) = "*" ! Group-Filter

&MACRO ASK_ITEM 5636096 (1 BOOL 0) = 0 ! Create 1 Output Group

&MACRO ASK_ITEM 6225920 (1 BOOL 0) = 0 ! Create RMS/Peak Stress Result

&MACRO ASK_ITEM 6422528 (1 OPTM 0) = 0 ! All

&MACRO ASK_ITEM 6422528 (1 OPTM 0) = 0 ! All

&MACRO ASK_ITEM 7602176 (1 STRN 0) = "*" ! Event Type-Filter (2)

!!!&MACRO EVENT FOCUS_IN 0 0, 4325376, 0, 0, 0! (Application CB Nested)

&MACRO FOCUS CHANGE IN 1

&MACRO MENU, 0, UG_HELP_SYSTEM_LOG UG_GATEWAY_MAIN_MENUBAR <RibbonFileBar->BackStageBar->LeftBackStageGroup->rbn_file_tab_help_cascade.csb> ## !

 

and in a Try... Catch Loop I get the error message

System.NullReferenceException: Object reference not set to an instance of an object

poiting to the line

 

iTopNValue = Blk101iTopNValue.GetProperties.GetInteger("Value")
Production: NX9.0.3.4, NX10.0.2.6
Development: VB.NET (amateur level !)

Re: Get value from UIBlock.IntegerBlock?

Phenom
Phenom

Thanks for the suggestion Yamada.

 

I have used similar coding method as the one in the examples and as it works never thought further. What I have seen coded is something like that

 

Dim propertyList As BlockStyler.PropertyList
propertyList = Blk101iTopNValue.GetProperties()
iTopNValue = propertyList.GetInteger("Value")

 where variable properyList is used for each widget

 

Jsut tested with Blk101iTopNValue.Value  and code still fails

I hav ehowever tested the proposed way of cdoing on another block (a slide bar) using

 

Dim slidebarchoice As Double =myslidebar.Value

 

and it seems to works

 

Might take the time to review this part of the code

 

Thanks  a lot

 

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

Re: Get value from UIBlock.IntegerBlock?

Siemens Phenom Siemens Phenom
Siemens Phenom

The relevant exception is "System.NullReferenceException: Object reference not set to an instance of an object". One of the two objects (Blk101iTopNValue or iTopNValue) is not instantiated properly. Check the scope of each. Stepping through the code in a debugger will help.

 

 

Re: Get value from UIBlock.IntegerBlock?

Phenom
Phenom

Looks like I may found the issue. In the function 'initialize_cb' I had

 

Blk101iTopNValue = CType(theDialog.TopBlock.FindBlock("Blki101TopNValue"), NXOpen.BlockStyler.IntegerBlock)

 

 

so the code was looking for the wrong name! should have read: "Blk101iTopNValue"

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