Transfer data between journals
Transfer data between journals
(OP)
Hey,
I have one problem:
I wrote journal for identifying data (curves and bodies) and calculated results.
I must use that journal several time and every time I must selected these same curves and bodies. (f.ex. I change only one dimension.)
Is it possibility divide my journal into two parts?
One for identifying curves and bodies and second for calculated results.
How can I pass data from one to the other journal?
Best regards
Michał Nowak
I have one problem:
I wrote journal for identifying data (curves and bodies) and calculated results.
I must use that journal several time and every time I must selected these same curves and bodies. (f.ex. I change only one dimension.)
Is it possibility divide my journal into two parts?
One for identifying curves and bodies and second for calculated results.
How can I pass data from one to the other journal?
Best regards
Michał Nowak





RE: Transfer data between journals
Better code directly thru MS Visual Studio and create your own external .dll functions you'd be able to call when needed in any of your main program.
RE: Transfer data between journals
Then retrieve that data in the text file from the other journal
RE: Transfer data between journals
I think write to file that's good idea.
Best regards
Michał Nowak
RE: Transfer data between journals
Use this code to save the selection (press the cancel button when you are done selecting objects).
CODE
Option Strict Off Imports System Imports NXOpen Module save_selection Sub Main() Dim theSession As Session = Session.GetSession() Dim workPart As Part = theSession.Parts.Work Dim displayPart As Part = theSession.Parts.Display Dim lw As ListingWindow = theSession.ListingWindow Dim mySelectedObject As NXObject lw.Open() Dim myDocs As String myDocs = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) Dim outputFile As String = IO.Path.Combine(myDocs, "selection.log") If IO.File.Exists(outputFile) Then Try IO.File.Delete(outputFile) Catch ex As Exception lw.WriteLine("error deleting file: " & outputFile) Return End Try End If Do Until SelectAnObject("Select object", _ mySelectedObject) = Selection.Response.Cancel lw.WriteLine("Object journal identifier: " & mySelectedObject.JournalIdentifier) lw.WriteLine("Object Tag: " & mySelectedObject.Tag) lw.WriteLine("Object Type: " & mySelectedObject.GetType.ToString) lw.WriteLine("") 'pass False to overwrite existing file, True to append existing file 'if file does not exist, a new file will be created and the True/False value will be ignored Using myWriter As New IO.StreamWriter(outputFile, True) myWriter.WriteLine(mySelectedObject.GetType.ToString) myWriter.WriteLine(mySelectedObject.JournalIdentifier) End Using Loop lw.Close() End Sub Function SelectAnObject(prompt As String, _ ByRef selObj As NXObject) As Selection.Response Dim theUI As UI = UI.GetUI Dim cursor As Point3d Dim typeArray() As Selection.SelectionType = _ {Selection.SelectionType.All} Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObject( _ prompt, "Selection", _ Selection.SelectionScope.AnyInAssembly, _ False, typeArray, selObj, cursor) If resp = Selection.Response.ObjectSelected Or _ resp = Selection.Response.ObjectSelectedByName Then Return Selection.Response.Ok Else Return Selection.Response.Cancel End If End Function End ModuleThen run this code to retrieve the saved selection. This code simply writes out the object's type, color, and layer to the information window to show that you have a reference to the previously chosen object.
CODE
Option Strict Off Imports System Imports NXOpen Module retrieve_selection Sub Main() Dim theSession As Session = Session.GetSession() Dim workPart As Part = theSession.Parts.Work Dim displayPart As Part = theSession.Parts.Display Dim lw As ListingWindow = theSession.ListingWindow lw.Open() Dim myDocs As String myDocs = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) Dim inputFile As String = IO.Path.Combine(myDocs, "selection.log") If Not IO.File.Exists(inputFile) Then lw.WriteLine("file not found: " & inputFile) Return End If Dim objType As String Dim identifier As String Using myReader As New IO.StreamReader(inputFile) Try objType = myReader.ReadLine identifier = myReader.ReadLine() While Not identifier Is Nothing Dim found As Boolean = False Dim theObject As DisplayableObject = Nothing lw.WriteLine("name: " & identifier) lw.WriteLine("type: " & objType) If objType.ToLower.Contains("point") Then theObject = workPart.Points.FindObject(identifier) found = True ElseIf objType.ToLower.Contains("line") Or _ objType.ToLower.Contains("arc") Or _ objType.ToLower.Contains("spline") Then theObject = workPart.FindObject(identifier) found = True ElseIf objType.ToLower.Contains("body") Then theObject = workPart.Bodies.FindObject(identifier) found = True Else lw.WriteLine("object type not currently supported, add it") lw.WriteLine("") End If If found Then Try 'theObject = CType(workPart.FindObject(identifier), DisplayableObject) lw.WriteLine("type: " & theObject.GetType.ToString) lw.WriteLine("color: " & theObject.Color.ToString) lw.WriteLine("layer: " & theObject.Layer.ToString) lw.WriteLine("") Catch ex As Exception lw.WriteLine(ex.Message) lw.WriteLine("") End Try End If objType = myReader.ReadLine identifier = myReader.ReadLine() End While Catch ex As Exception lw.WriteLine(ex.Message) End Try End Using lw.Close() End Sub End Modulewww.nxjournaling.com
RE: Transfer data between journals
I have another one small question: Is it possible with face (This way - not - I tested it)?
In this moment I can do my journals using body (and select faces in main journal).
I think about write Face.Tag to file. But how find face by tag?
Something like this:
CODE -->
But when I will work with thousand faces...
Maybe somebody have some easer idea.
Best regards
Michał Nowak
RE: Transfer data between journals
www.nxjournaling.com
RE: Transfer data between journals