NXOpen.BlockStyler.UIBlock
NXOpen.BlockStyler.UIBlock
(OP)
Hi all,
I'm new to NXopen and I have a quite silly question; how I add items in a listbox and bitmaps in a dialog created by the blockstyler?
I thought the obvious answer will be something like this:
Public Function update_cb(ByVal block As NXOpen.BlockStyler.UIBlock) As Integer
Try
If block Is list_box0 Then
Dim list_box0Props As PropertyList = list_box0.GetProperties()
list_box0Props.AddItem("value")
End If
But I'm getting the error that "AddItem" is not a member NXOpen.Blockstyler.Property. What I'm doing wrong?
Thanks,
Zoes
I'm new to NXopen and I have a quite silly question; how I add items in a listbox and bitmaps in a dialog created by the blockstyler?
I thought the obvious answer will be something like this:
Public Function update_cb(ByVal block As NXOpen.BlockStyler.UIBlock) As Integer
Try
If block Is list_box0 Then
Dim list_box0Props As PropertyList = list_box0.GetProperties()
list_box0Props.AddItem("value")
End If
But I'm getting the error that "AddItem" is not a member NXOpen.Blockstyler.Property. What I'm doing wrong?
Thanks,
Zoes





RE: NXOpen.BlockStyler.UIBlock
You are close to your goal. After calling GetProperties() you will need to call SetStrings(), e.g.
PropertyList.SetStrings("ListItems", <your list here>)
where <your list here> is of type String(), e.g. an array of strings you wish to fill the list with. "ListItems" is the property keyword used by the ListBox to get/set the items in that list.
Therefore your example should look something like (untested!):
CODE
Dim list_box0Props As PropertyList = list_box0.GetProperties()
Dim listbox0Values() as String = {"value"}
list_box0Props.SetStrings("ListItems", list_box0Values)
End If
Marc
NX Software Developer
RE: NXOpen.BlockStyler.UIBlock
The error now is that listbox0Values needs to be declared.
That's confusing. I can see that the listbox0Values is String, what more does it need?
RE: NXOpen.BlockStyler.UIBlock
CODE
Marc
NX Software Developer
RE: NXOpen.BlockStyler.UIBlock
RE: NXOpen.BlockStyler.UIBlock
Marc
NX Software Developer
RE: NXOpen.BlockStyler.UIBlock
RE: NXOpen.BlockStyler.UIBlock
You will need to place the code in initialize_cb(), which will fill your list box as soon as your dialog appears:
CODE
Try
group0 = CType(theDialog.TopBlock.FindBlock("group0"), NXOpen.BlockStyler.UIBlock)
label0 = CType(theDialog.TopBlock.FindBlock("label0"), NXOpen.BlockStyler.UIBlock)
list_box0 = CType(theDialog.TopBlock.FindBlock("list_box0"), NXOpen.BlockStyler.ListBox)
Dim list_box0Props As PropertyList = list_box0.GetProperties()
Dim list_box0Values() As String = {"value"}
list_box0Props.SetStrings("ListItems", list_box0Values)
Catch ex As Exception
'---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
End Try
End Subx
Marc
NX Software Developer
RE: NXOpen.BlockStyler.UIBlock
Ps: to upload an image in the "label0", will follow similar code?
RE: NXOpen.BlockStyler.UIBlock
CODE
e.g.
CODE
Marc
NX Software Developer
RE: NXOpen.BlockStyler.UIBlock
Thanks Marc
RE: NXOpen.BlockStyler.UIBlock
I would appreciate it if you thanked me for my valuable post(s) by clicking on "Thank MarkyMON for this valuable post!" :)
Marc
NX Software Developer
RE: NXOpen.BlockStyler.UIBlock
RE: NXOpen.BlockStyler.UIBlock
Marc
NX Software Developer
RE: NXOpen.BlockStyler.UIBlock
expression0 = CType(theDialog.TopBlock.FindBlock("expression0"), NXOpen.BlockStyler.UIBlock)
Can you configure it to load the "thickness" expression for the user to edit from there instead for opening it from Tools -> Expressions?
RE: NXOpen.BlockStyler.UIBlock
CODE
Marc
NX Software Developer
RE: NXOpen.BlockStyler.UIBlock
RE: NXOpen.BlockStyler.UIBlock
This is what needs to happen:
1. Find the work part's thickness expression. This will be a NXOpen.Expression object.
2. In the initialize_cb(), the expression's ExpressionObject needs to be set the to the work part's thickness expression.
According to the NX help:
This means that any changes to the block (e.g. change of value) will also change the value of the expression (in your case, thickness).
Please send me the code so I can implement the changes.
Marc
NX Software Developer
RE: NXOpen.BlockStyler.UIBlock
Tried to call the expression like this and attribute its value to a string variable:
Dim expression0 As Expression = CType(workPart.Expressions.FindObject("thickness"), Expression)
Dim thickness As String = expression1.Value.ToString
Still I'm not sure if I'm in the right track.
Here is the code.
RE: NXOpen.BlockStyler.UIBlock
CODE
Try
group0 = CType(theDialog.TopBlock.FindBlock("group0"), NXOpen.BlockStyler.UIBlock)
expression0 = CType(theDialog.TopBlock.FindBlock("expression0"), NXOpen.BlockStyler.UIBlock)
Dim thicknessExp as Expression = CType(theSession.Parts.Work.Expressions.FindObject("thickness"), Expression)
If thicknessExp IsNot Nothing Then
expression0.GetProperties.SetTaggedObject("ExpressionObject", thicknessExp)
End If
Catch ex As Exception
'---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
End Try
End Sub
From GTAC:
It basically means that if you have a standalone expression and it is not referenced by another expression, then that standalone expression is deleted when clicking OK or Apply in the dialog.
Marc
NX Software Developer
RE: NXOpen.BlockStyler.UIBlock
RE: NXOpen.BlockStyler.UIBlock
I'm not exactly sure what you mean. It should depend on how the expression is being used in the (work) part...
Marc
NX Software Developer
RE: NXOpen.BlockStyler.UIBlock
In order for the new value to be applied to the work part you need to go Tools-> Expressions -> Apply, then you can see the workpart increase size.
Is there any code line to update the workpart based on the current expressions's values? Update (regenerate) the display?
RE: NXOpen.BlockStyler.UIBlock
Marc
NX Software Developer
RE: NXOpen.BlockStyler.UIBlock
I wonder if it has to do with something like that:
Dim markId3 As Session.UndoMarkId
markId3 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Update Expression Data")
RE: NXOpen.BlockStyler.UIBlock
Marc
NX Software Developer
RE: NXOpen.BlockStyler.UIBlock
RE: NXOpen.BlockStyler.UIBlock
Marc
NX Software Developer
RE: NXOpen.BlockStyler.UIBlock
RE: NXOpen.BlockStyler.UIBlock
Marc
NX Software Developer
RE: NXOpen.BlockStyler.UIBlock
RE: NXOpen.BlockStyler.UIBlock
Marc
NX Software Developer
RE: NXOpen.BlockStyler.UIBlock
RE: NXOpen.BlockStyler.UIBlock
RE: NXOpen.BlockStyler.UIBlock
RE: NXOpen.BlockStyler.UIBlock
nErrs1 = theSession.UpdateManager.DoUpdate(id1)