alj722
Aerospace
- Nov 4, 2004
- 39
Greetings,
I'm working on a Journal file (haven't done much of this before) where I do the following:
1) Select a bunch of lines
2) Select a bunch of faces
3) Pick an origin point (or simply use the WCS location or the start point of one of the lines)
4) Dump out a file (preferably a comma separated text file) that lists:
Line ID: (or startpoint/endpoint)
Face ID:
Face's Owning Body: (for the purpose of getting the body's material)
Intersection Point: (maybe with some flag such as None, when no intersection)
I have it so I can select all the curves and select all the faces and loop through them, but I can't figure out how to get the intersection point. Attached is the code (some of it adapted from a sample on NXJournaling.com). Anyone done anything like this. Also, is anyone aware of a class on writing NX Journals?
Drew Jones
I'm working on a Journal file (haven't done much of this before) where I do the following:
1) Select a bunch of lines
2) Select a bunch of faces
3) Pick an origin point (or simply use the WCS location or the start point of one of the lines)
4) Dump out a file (preferably a comma separated text file) that lists:
Line ID: (or startpoint/endpoint)
Face ID:
Face's Owning Body: (for the purpose of getting the body's material)
Intersection Point: (maybe with some flag such as None, when no intersection)
I have it so I can select all the curves and select all the faces and loop through them, but I can't figure out how to get the intersection point. Attached is the code (some of it adapted from a sample on NXJournaling.com). Anyone done anything like this. Also, is anyone aware of a class on writing NX Journals?
Drew Jones
Code:
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.Assemblies
Module Module1
Sub Main()
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim lw As ListingWindow = theSession.ListingWindow
lw.Open()
Dim myVectors() As TaggedObject
If SelectVectors("Select Vectors", myVectors) = Selection.Response.Cancel Then
Return
End If
Dim myFaces() As TaggedObject
If SelectFaces("Select Faces", myFaces) = Selection.Response.Cancel Then
Return
End If
For Each tempVector As Line In myVectors
lw.WriteLine("Curve Name: " & tempVector.Name)
lw.WriteLine(tempVector.StartPoint.ToString)
lw.WriteLine(tempVector.EndPoint.ToString)
For Each tempFace As Face In myFaces
lw.WriteLine("Owning Body: " & tempFace.GetBody.OwningComponent.ToString)
lw.WriteLine("Face Color: " & tempFace.Color)
' THIS DOESN'T WORK: lw.WriteLine("Intersection: " & UFCurve.Intersect(tempVector,tempFace,tempVector.StartPoint))
Next
Next
End Sub
Function SelectVectors(ByVal prompt As String, ByRef selObj() As TaggedObject) As Selection.Response
Dim theUI As UI = UI.GetUI
Dim title As String = "Select Vectors"
Dim includeFeatures As Boolean = False
Dim keepHighlighted As Boolean = False
Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific
Dim scope As Selection.SelectionScope = Selection.SelectionScope.AnyInAssembly
Dim selectionMask_array(0) As Selection.MaskTriple
With selectionMask_array(0)
.Type = UFConstants.UF_line_type
.Subtype = UFConstants.UF_line_normal_subtype
End With
Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObjects(prompt, _
title, scope, selAction, _
includeFeatures, keepHighlighted, selectionMask_array, _
selobj)
If resp = Selection.Response.Ok Then
Return Selection.Response.Ok
Else
Return Selection.Response.Cancel
End If
End Function
Function SelectFaces(ByVal prompt As String, ByRef selObj() As TaggedObject) As Selection.Response
Dim theUI As UI = UI.GetUI
Dim title As String = "Select Faces"
Dim includeFeatures As Boolean = False
Dim keepHighlighted As Boolean = False
Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific
Dim scope As Selection.SelectionScope = Selection.SelectionScope.AnyInAssembly
Dim selectionMask_array(0) As Selection.MaskTriple
With selectionMask_array(0)
.Type = UFConstants.UF_face_type
' .Subtype = UFConstants.UF_line_normal_subtype
End With
Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObjects(prompt, _
title, scope, selAction, _
includeFeatures, keepHighlighted, selectionMask_array, _
selobj)
If resp = Selection.Response.Ok Then
Return Selection.Response.Ok
Else
Return Selection.Response.Cancel
End If
End Function
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