Brand new to Journaling
Brand new to Journaling
(OP)
Hello everyone,
I am just getting started with Journaling and am wondering if there is a file/list someplace of generic NX callouts someplace. I would like to start by creating a journal that will allow the user to select various objects (lines/arcs) and then I want to print out/use information related to those objects. Start point, end point, arc centers etc.
I started with this:
Option Strict Off
Imports System
Imports NXOpen
Module NXJournal
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 mySelectedObjects as NXObject()
lw.Open
If SelectObjects("Hey, select multiple somethings", _
mySelectedObjects) = Selection.Response.Ok Then
lw.WriteLine("You selected " & mySelectedObjects.Length & " object(s)")
lw.WriteLine("")
For Each mySelObj As NXObject in mySelectedObjects
lw.WriteLine("Object Tag: " & mySelObj.Tag)
lw.WriteLine("Object Type: " & mySelObj.GetType.ToString)
lw.WriteLine("")
Next
theSession.Information.DisplayObjectsDetails(mySelectedObjects)
End if
' The close method closes the text stream to the window,
' it does not close the window itself
' (use the .CloseWindow() method for that).
' Also, if you are using the listing window to write
' to a file, the close method will clean up and close the file.
lw.Close
End Sub
Function SelectObjects(prompt As String, _
ByRef selObj as NXObject()) As Selection.Response
Dim theUI As UI = UI.GetUI
Dim typeArray() As Selection.SelectionType = _
{Selection.SelectionType.All, _
Selection.SelectionType.Faces, _
Selection.SelectionType.Edges, _
Selection.SelectionType.Features}
Dim resp As Selection.Response = theUI.SelectionManager.SelectObjects( _
prompt, "Selection", _
Selection.SelectionScope.AnyInAssembly, _
False, typeArray, selobj)
If resp = Selection.Response.ObjectSelected Or _
resp = Selection.Response.ObjectSelectedByName Or _
resp = Selection.Response.OK Then
Return Selection.Response.Ok
Else
return Selection.Response.Cancel
End If
End Function
End Module
The problem here is that theSession.Information.DisplayObjectsDetails(mySelectedObjects) spits out everything for every object all at the same time and I want to be able to store/manipulate individual parts of that information. Am I thinking about this the wrong way or do I just need to learn what all of the callouts are?
I am just getting started with Journaling and am wondering if there is a file/list someplace of generic NX callouts someplace. I would like to start by creating a journal that will allow the user to select various objects (lines/arcs) and then I want to print out/use information related to those objects. Start point, end point, arc centers etc.
I started with this:
Option Strict Off
Imports System
Imports NXOpen
Module NXJournal
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 mySelectedObjects as NXObject()
lw.Open
If SelectObjects("Hey, select multiple somethings", _
mySelectedObjects) = Selection.Response.Ok Then
lw.WriteLine("You selected " & mySelectedObjects.Length & " object(s)")
lw.WriteLine("")
For Each mySelObj As NXObject in mySelectedObjects
lw.WriteLine("Object Tag: " & mySelObj.Tag)
lw.WriteLine("Object Type: " & mySelObj.GetType.ToString)
lw.WriteLine("")
Next
theSession.Information.DisplayObjectsDetails(mySelectedObjects)
End if
' The close method closes the text stream to the window,
' it does not close the window itself
' (use the .CloseWindow() method for that).
' Also, if you are using the listing window to write
' to a file, the close method will clean up and close the file.
lw.Close
End Sub
Function SelectObjects(prompt As String, _
ByRef selObj as NXObject()) As Selection.Response
Dim theUI As UI = UI.GetUI
Dim typeArray() As Selection.SelectionType = _
{Selection.SelectionType.All, _
Selection.SelectionType.Faces, _
Selection.SelectionType.Edges, _
Selection.SelectionType.Features}
Dim resp As Selection.Response = theUI.SelectionManager.SelectObjects( _
prompt, "Selection", _
Selection.SelectionScope.AnyInAssembly, _
False, typeArray, selobj)
If resp = Selection.Response.ObjectSelected Or _
resp = Selection.Response.ObjectSelectedByName Or _
resp = Selection.Response.OK Then
Return Selection.Response.Ok
Else
return Selection.Response.Cancel
End If
End Function
End Module
The problem here is that theSession.Information.DisplayObjectsDetails(mySelectedObjects) spits out everything for every object all at the same time and I want to be able to store/manipulate individual parts of that information. Am I thinking about this the wrong way or do I just need to learn what all of the callouts are?





RE: Brand new to Journaling
CODE
www.nxjournaling.com
RE: Brand new to Journaling
RE: Brand new to Journaling
Denis Huskic
Data Prep
Kettering University
Class of '17
RE: Brand new to Journaling
What exactly would you like to filter?
We can add edges into the mix then it would let you select any line, arc, or edge; is this what you want?
www.nxjournaling.com
RE: Brand new to Journaling
If it worked the same as the arcs in the above example, and returned only a diameter, then it would be perfect!
Denis Huskic
Data Prep
Kettering University
Class of '17
RE: Brand new to Journaling
CODE -->
Option Strict Off Imports System Imports NXOpen Imports NXOpen.UF Imports NXOpen.Features Module ArcEdges Dim s As Session = Session.GetSession() Dim ufs As UFSession = UFSession.GetUFSession() Dim workPart As Part = s.Parts.Work Sub Main() Dim response0 As Selection.Response = Selection.Response.Cancel Dim edge1 As Edge = Nothing Dim arc1 As Arc = Nothing Dim edgetype1 As Integer = Nothing Dim arc_evaluator As System.IntPtr Dim dia1 As Double = Nothing Dim arc_data As NXOpen.UF.UFEval.Arc = Nothing start1: response0 = SelectAEdge(edge1) If response0 = Selection.Response.Cancel Then GoTo end1 ufs.Modl.AskEdgeType(edge1.Tag, edgetype1) If edgetype1 = 3002 Then ufs.Eval.Initialize(edge1.Tag, arc_evaluator) ufs.Eval.AskArc(arc_evaluator, arc_data) dia1 = 2.0 * arc_data.radius MsgBox(dia1.ToString) End If GoTo start1 end1: End Sub Public Function SelectAEdge(ByRef selectedObject As Edge) As Selection.Response Dim ui As UI = ui.GetUI Dim message As String = "Select a Edge" Dim title As String = "Selection" Dim scope As Selection.SelectionScope = Selection.SelectionScope.WorkPart Dim keepHighlighted As Boolean = True Dim includeFeatures As Boolean = True Dim response As Selection.Response Dim selectionAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific Dim selectionMask_array(1) As Selection.MaskTriple With selectionMask_array(0) .Type = UFConstants.UF_solid_type .Subtype = UFConstants.UF_solid_body_subtype .SolidBodySubtype = NXOpen.UF.UFConstants.UF_UI_SEL_FEATURE_CIRCULAR_EDGE End With Dim cursor As Point3d response = ui.SelectionManager.SelectObject(message, title, scope, _ selectionAction, includeFeatures, _ False, selectionMask_array, _ selectedObject, cursor) If response = Selection.Response.Cancel Or response = Selection.Response.Back Then Return Selection.Response.Cancel Else Return Selection.Response.Ok End If End Function Public Function GetUnloadOption(ByVal dummy As String) As Integer 'Unloads the image immediately after execution within NX GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately End Function End ModuleRegards
Frank Swinkels
RE: Brand new to Journaling
I was able to add parts of Frank's journal to Cowski's to get it to return what I was looking for.
Where the
CODE --> vb
CODE --> vb
If TypeOf myObject Is Line Then myLine = myObject lw.WriteLine("selected object is a line") lw.WriteLine("start point: " & myLine.StartPoint.ToString) lw.WriteLine("end point: " & myLine.EndPoint.ToString) lw.WriteLine("length: " & FormatNumber(myLine.GetLength.ToString, 4)) ElseIf TypeOf myObject Is Arc Then myArc = myObject lw.WriteLine("selected object is an arc") lw.WriteLine("diameter: " & FormatNumber((myArc.Radius * 2).ToString,4)) Else edge1 = myObject ufs.Eval.Initialize(edge1.Tag, arc_evaluator) ufs.Eval.AskArc(arc_evaluator, arc_data) dia1 = 2.0 * arc_data.radius lw.WriteLine("selected object is an edge") lw.WriteLine("diameter: " & FormatNumber(dia1.ToString,4)) End If lw.WriteLine("")I also added another bit to the MaskTriple array
CODE --> vb
With selectionMask_array(2) .Type = UFConstants.UF_solid_type .Subtype = UFConstants.UF_solid_body_subtype .SolidBodySubtype = NXOpen.UF.UFConstants.UF_UI_SEL_FEATURE_CIRCULAR_EDGE End WithThanks for all the help!
Denis Huskic
Data Prep
Kettering University
Class of '17
RE: Brand new to Journaling
I was wondering the same thing.
RE: Brand new to Journaling
www.nxjournaling.com