Expressions in VB
Expressions in VB
(OP)
Hi,
Can anyone give me any advice of how to check if a specific (named) expression variable has been set from the user using Block styler with VB?
Any help appreciated,
Thank you,
P.
Can anyone give me any advice of how to check if a specific (named) expression variable has been set from the user using Block styler with VB?
Any help appreciated,
Thank you,
P.





RE: Expressions in VB
RE: Expressions in VB
I want to use expressions or get directly the drawn dimensions of objects through the block styler (interface) saved in VB code.
RE: Expressions in VB
Is this what you are looking for?
Frank Swinkels
RE: Expressions in VB
So far I got the named expressions displayed and now im trying, according what their values are, output messages in a multiline_string box (as defined from the blockstyler).
The thing that causes me headache is the way you output messages in this box (multiline_string); I have tried
Dim ExpressionString As String = expression1.Value.ToString
Dim multiline_string0 As PropertyList = multiline_string0.SetStrings("Expression", ExpressionString)
Also
multiline_string0.Text = expression1.Value.ToString
or
multiline_string0.SetStrings ...
or
multiline_string0.Show ...
Nothing work. Any ideas?
RE: Expressions in VB
Dim expValues(-1) As String
response = select_feature(feat)
ufs.Modl.AskExpDescOfFeat(feat.Tag, noExps, expdescstrings, _ exptags)
For i As Integer = 0 To noExps - 1
exp = NXObjectManager.Get(exptags(i))
ReDim Preserve expValues(i)
expValues(i) = exp.RightHandSide
Next
Dim multiline_string0Props As PropertyList = _ multiline_string0.GetProperties
multiline_string0Props.SetStrings("Value", expValues)
The differences from the code you had are:
1) For the expression values you need to ask for the RightHandSide
i.e. expValues(i) = exp.RightHandSide
2) Since features may have different number of expressions therefore we need to read the expression values into a string array. The relevant code is:
Dim expValues(-1) As String
For i As Integer = 0 To noExps - 1
exp = NXObjectManager.Get(exptags(i))
ReDim Preserve expValues(i)
expValues(i) = exp.RightHandSide
Next
3) You need to create a PropertyList and set the multi line string using:
Dim multiline_string0Props As PropertyList = _ multiline_string0.GetProperties
multiline_string0Props.SetStrings("Value", expValues)
Hope this helps.
Frank Swinkels
RE: Expressions in VB
RE: Expressions in VB
Expressions are already converted to strings.. is it difficult to search and compared for a example a named expression from the user i.e p1?
RE: Expressions in VB
This code:
Dim expValues(-1) As String
For i As Integer = 0 To noExps - 1
exp = NXObjectManager.Get(exptags(i))
ReDim Preserve expValues(i)
expValues(i) = exp.RightHandSide
Next
Dim list_box0Properties As PropertyList = list_box0.GetProperties()
list_box0Properties.SetStrings("Value", stringArray:=expValues)
Causes the error: Invalid name property for the block. Whereas if I change the "Value" to "ListItems" shows nothing.
What's is going on?
RE: Expressions in VB
list_box0Properties.SetStrings("ListItems", expValues)
It is also probable that you need to change a line in the initialize_cb() sub. This should read
list_box0 = CType(theDialog.TopBlock.FindBlock("list_box0"), NXOpen.BlockStyler.ListBox)
I think yours probably still has ("multiline_string0") in it.
Frank Swinkels
RE: Expressions in VB
or
in the version that there is a multiline_string0
multiline_string0Props.SetStrings("Value", expValues)
The initialize_cb() is correct.
I have tried few things nothing worked.
RE: Expressions in VB
Frank Swinkels
fsw13678@bigpond.net.au
RE: Expressions in VB
RE: Expressions in VB
Dim expTitle(-1) As String
Dim workPart As Part = s.Parts.Work
Dim count As Integer = 0
For Each eachexp As Expression In workPart.Expressions
ReDim Preserve expTitle(count)
expTitle(count) = eachexp.Name
count += 1
Next
Dim list_box0Props As PropertyList = list_box0.GetProperties()
list_box0Props.SetStrings("ListItems", expTitle)
Hope this helps
Frank Swinkels
RE: Expressions in VB
What I was actually wanted to achieve is to display both value and name of expressions in a textbox and then compare / validate them through another piece of code. To do that i thought I needed to convert the expresssions into strings and then compare them against a set of rules.
Thank you,
P.