Zmiana w Journal-u

NX CAM/Unigraphics

Autor tematu
devon58
Nowy użytkownik, używaj wyszukiwarki
Nowy użytkownik, używaj wyszukiwarki
Posty w temacie: 2
Posty: 7
Rejestracja: 01 sty 2016, 22:29

Zmiana w Journal-u

#1

Post napisał: devon58 » 01 sty 2016, 22:37

Witam, w sieci znalazłem bardzo przydatny dla mnie journal ale chciałbym wprowadzić drobną zmianę niestety kompletnie nie znam się na VB.
Journal kopiuje do schowka współrzedne punktu jednak robi to w jeden lini a chciałbym aby współrzędne znajdowały się jedna pod drugą

Kod: Zaznacz cały

April 3, 2014
'select points on screen, copy information to clipboard

Option Strict Off
Imports System
Imports System.Collections.Generic
Imports System.Windows.Forms
Imports NXOpen
Imports NXOpen.UF

Module Module1

    Sub Main()

        Dim theSession As Session = Session.GetSession()
        Dim theUfSession As UFSession = UFSession.GetUFSession

        If IsNothing(theSession.Parts.Work) Then
            'active part required
            Return
        End If

        Dim workPart As Part = theSession.Parts.Work

        Dim pointValues As New List(Of String)
        Dim response1 As Integer = Nothing
        Dim mode1() As Integer = {0, 0}
        Dim pointDisplayMode As Integer = 0
        Dim objectpoint(2) As Double

        Do
            theUfSession.Ui.LockUgAccess(NXOpen.UF.UFConstants.UF_UI_FROM_CUSTOM)
            response1 = theUfSession.Ui.PointSubfunction("Select Point", mode1, pointDisplayMode, objectpoint)
            theUfSession.Ui.UnlockUgAccess(NXOpen.UF.UFConstants.UF_UI_FROM_CUSTOM)

            If response1 = 5 Then
                Dim myPtVal As String = "X = " & objectpoint(0).ToString("N2") & " Y = " & objectpoint(1).ToString("N2") & " Z = " & objectpoint(2).ToString("N2")
                                                                       
            If pointValues.Contains(myPtVal) Then
                    Exit Do
                Else
                    pointValues.Add(myPtVal)
                End If
            End If

        Loop Until response1 <> 5

        Dim myStringBuilder As New Text.StringBuilder
        For Each pt As String In pointValues
            myStringBuilder.Append(pt)
            myStringBuilder.AppendLine()
        Next

        Clipboard.SetText(myStringBuilder.ToString)

    End Sub


    Public Function GetUnloadOption(ByVal dummy As String) As Integer

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

        '----Other unload options-------
        'Unloads the image immediately after execution within NX
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

        'Unloads the image explicitly, via an unload dialog
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly
        '-------------------------------

    End Function

End Module 



Tagi:


satsun
Sympatyk forum poziom 2 (min. 50)
Sympatyk forum poziom 2 (min. 50)
Posty w temacie: 1
Posty: 52
Rejestracja: 26 lis 2011, 14:40
Lokalizacja: Częstochowa/Warszawa

Re: Zmiana w Journal-u

#2

Post napisał: satsun » 07 sty 2016, 01:46

Kod: Zaznacz cały

April 3, 2014
'select points on screen, copy information to clipboard

Option Strict Off
Imports System
Imports System.Collections.Generic
Imports System.Windows.Forms
Imports NXOpen
Imports NXOpen.UF

Module Module1

    Sub Main()

        Dim theSession As Session = Session.GetSession()
        Dim theUfSession As UFSession = UFSession.GetUFSession

        If IsNothing(theSession.Parts.Work) Then
            'active part required
            Return
        End If

        Dim workPart As Part = theSession.Parts.Work

        Dim pointValues As New List(Of String)
        Dim response1 As Integer = Nothing
        Dim mode1() As Integer = {0, 0}
        Dim pointDisplayMode As Integer = 0
        Dim objectpoint(2) As Double

        Do
            theUfSession.Ui.LockUgAccess(NXOpen.UF.UFConstants.UF_UI_FROM_CUSTOM)
            response1 = theUfSession.Ui.PointSubfunction("Select Point", mode1, pointDisplayMode, objectpoint)
            theUfSession.Ui.UnlockUgAccess(NXOpen.UF.UFConstants.UF_UI_FROM_CUSTOM)

            If response1 = 5 Then
                Dim myPtVal As String = "X = " & objectpoint(0).ToString("N2") & VbCrLf & " Y = " & objectpoint(1).ToString("N2") & VbCrLf & " Z = " & objectpoint(2).ToString("N2")
                                                                       
            If pointValues.Contains(myPtVal) Then
                    Exit Do
                Else
                    pointValues.Add(myPtVal)
                End If
            End If

        Loop Until response1 <> 5

        Dim myStringBuilder As New Text.StringBuilder
        For Each pt As String In pointValues
            myStringBuilder.Append(pt)
            myStringBuilder.AppendLine()
        Next

        Clipboard.SetText(myStringBuilder.ToString)

    End Sub


    Public Function GetUnloadOption(ByVal dummy As String) As Integer

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

        '----Other unload options-------
        'Unloads the image immediately after execution within NX
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately

        'Unloads the image explicitly, via an unload dialog
        'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly
        '-------------------------------

    End Function

End Module 
Spróbuj takiej wersji, też niezbyt znam się na VB ale powinno działać. Poinformuj w temacie o efekcie. Jak coś będziemy probować dalej.


Autor tematu
devon58
Nowy użytkownik, używaj wyszukiwarki
Nowy użytkownik, używaj wyszukiwarki
Posty w temacie: 2
Posty: 7
Rejestracja: 01 sty 2016, 22:29

#3

Post napisał: devon58 » 08 sty 2016, 10:07

Dokładnie o to mi chodziło, dzięki za pomoc!

Pozdrawiam

ODPOWIEDZ Poprzedni tematNastępny temat

Wróć do „NX CAM/Unigraphics”