×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Expressions in VB

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.

RE: Expressions in VB

Is your specific question about accessing the expression with VB or using the block styler?

RE: Expressions in VB

(OP)
Thank you for your reply,

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

I am not certail that the attached simple vb code gives you an insight to what you are looking for.  The code lets you select a feature and lists the feature expression descripion and expression equation.  I asume that you can then place the correct expression values in the Block Styler for users to edit.

Is this what you are looking for?

Frank Swinkels

RE: Expressions in VB

(OP)
I have seen this code. Trying to simplify it.
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

Ok if you want the expression values below is a portion of the relevant code

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

(OP)
So for the late reply; Thank you very much for your help :)

RE: Expressions in VB

(OP)
I was wondering if there is a specific command for comparing expressions through the VB.net code..

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

(OP)
One more question..

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

Since you changed from from a multiline string box to a list box you need to use
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

(OP)
Still, nothing appears in the list box list_box0Properties.SetStrings("ListItems", expValues)
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

If the list box or multi line string box do not show any entries nor throw any errors than we must assume that no expressions have been found.  The only reason I can think of is that you might be selecting a body and not a feature.  Using either method I get entries in the display when I select a feature.  I would need to see more code (especially for selecting a feature) to be able to comment further.

Frank Swinkels
fsw13678@bigpond.net.au
 

RE: Expressions in VB

(OP)
To be honest with you I thought I would be able to load all the expressions values of all the objects/features displayed without selecting a specific one. The moment the app lances it will load all the available expressions in string format inside this multiline or list box. I suppose, that's not possible?  

 

RE: Expressions in VB

OK to get all expression in the current work part the following code snippet will do it.  In looking back at the initial question I think what you are asking for is not the expression values but rather the expression name. Please remember that there are many ways to program any specific requirement and that one needs to be very specific regarding one's request for help.

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

(OP)
Thank you very much for all your help. I should be more specific for future requests for help.

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources