×
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

Journal and expressions

Journal and expressions

Journal and expressions

(OP)
Is there a way to assign the value of a journal variable to an expression?
The value comes from a VB form, so it is a number, but in a string. I want to use this in a length type expression.
I tried to convert it to Double, but not worked.
any suggestions are appreciated

----
kukelyk

RE: Journal and expressions

Here's a quick example:

CODE

Option Strict Off  
Imports System  
Imports NXOpen  

Module Module1  

    Sub Main()  

        Dim theSession As Session = Session.GetSession()  
        Dim workPart As Part = theSession.Parts.Work  

        Dim myExpName As String = "test"  
        Dim myStringValue As String = "2.71828"  
        Dim myNewStringValue As String = "6.283185"  

        Dim expression1 As Expression  
        Dim expExists As Boolean = False  
        For Each myExp As Expression In workPart.Expressions.ToArray  
            If myExp.Name = myExpName Then  
                expExists = True  
                expression1 = myExp  
                Exit For  
            End If  
        Next  

        Dim markId1 As Session.UndoMarkId  
        markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Expression")  

        Dim unit1 As Unit = CType(workPart.UnitCollection.FindObject("Inch"), Unit)  

        If Not expExists Then  
            expression1 = workPart.Expressions.CreateWithUnits(myExpName & "=" & myStringValue, unit1)  
        Else  
            expression1.RightHandSide = myNewStringValue  
        End If  

        Dim nErrs1 As Integer  
        nErrs1 = theSession.UpdateManager.DoUpdate(markId1)  

    End Sub  


    Public Function GetUnloadOption(ByVal dummy As String) As Integer  

 'Unloads the image when the NX session terminates
        GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination  

    End Function  

End Module 

www.nxjournaling.com

RE: Journal and expressions

(OP)
Thanks for your attention, tomorrow i will try it.

----
kukelyk

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