Extract XYZ points from a Journal file.
Extract XYZ points from a Journal file.
(OP)
I have already spent a great deal of time searching the forum, but I have not found a solution. We use NX 7.5.
I'm creating a tube drawing (a vacuum line w/several bends). I have a point and the start and at the intersections and at the end. I placed the WCS and the start point (labeled "A" and so on). I would like to execute a Journal file to retrieve the XYZ coordinates of the points, and if possible, also retrieve the bend radii (labeled as "A1", "B1", etc...). Whereby this information would be the input for a xls table.
Any suggestions would be greatly appreciated!
I'm creating a tube drawing (a vacuum line w/several bends). I have a point and the start and at the intersections and at the end. I placed the WCS and the start point (labeled "A" and so on). I would like to execute a Journal file to retrieve the XYZ coordinates of the points, and if possible, also retrieve the bend radii (labeled as "A1", "B1", etc...). Whereby this information would be the input for a xls table.
Any suggestions would be greatly appreciated!





RE: Extract XYZ points from a Journal file.
htt
John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
http://www.siemens.com/plm
UG/NX Museum: http://www.plmworld.org/p/cm/ld/fid=209
To an Engineer, the glass is twice as big as it needs to be.
RE: Extract XYZ points from a Journal file.
RE: Extract XYZ points from a Journal file.
What format would you like to see the output? Perhaps upload an example file, and/or post some example data.
RE: Extract XYZ points from a Journal file.
I used it many years ago (pre V10) when I worked for a company that made automotivr exhausts.
RE: Extract XYZ points from a Journal file.
RE: Extract XYZ points from a Journal file.
RE: Extract XYZ points from a Journal file.
RE: Extract XYZ points from a Journal file.
RE: Extract XYZ points from a Journal file.
What I am looking to do is get XYZ coordinate data for points on a specific layer (Usually between 8 and 12 points) to input into a table in the part drawing. Ideally, this would be completely automated, but what I am asking above would be a pretty good stopgap and require a fairly small amount of user-input.
RE: Extract XYZ points from a Journal file.
Man if you can answer this I owe you a beer!!
RE: Extract XYZ points from a Journal file.
Below is a quick update to the code, it now also reports the distance from the last point (starting at point #2) and the angle the 3 points make (starting at point #3). The name attribute thing is optional, if the 'created by' order is working we can eliminate it. My concern is, if you later edit the pipe by adding more points/arcs in the middle, it will throw off the reported list. I have an idea that I'll explore tomorrow, if it looks feasible I'll post back.
kfraysur,
Sorry, didn't mean to ignore your last post, it just fell off my radar. I'm not sure it is possible to add it directly to the part spreadsheet, I'll have to look into that.
Updated code:
CODE
Imports System
Imports System.Collections
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpenUI
Imports NXOpen.UF
Module NXJournal
Dim ufs As UFSession = UFSession.GetUFSession()
Sub Main()
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
Dim myMeasure As Measu reManager = workPart.MeasureManager
'layer to interrogate
Dim layerNumber As Integer = 1
Dim lw As ListingWindow = theSession.ListingWindow
Dim allObjects As NXObject()
Dim pointXYZ As Point3d
Dim arcObject As Arc
Dim myPoints As New List(Of Point)
Dim myArcs As New List(Of Arc)
Dim pointName As String
Dim arcName As String
Dim i As Integer = 0
Dim unit1 As Unit
Dim myDistance As MeasureDistance
Dim myAngle As MeasureAngle
If workPart.PartUnits = BasePart.Units.Inches Then
unit1 = CType(workPart.UnitCollection.FindObject("Inch"), Unit)
Else
unit1 = CType(workPart.UnitCollection.FindObject("MilliMeter"), Unit)
End If
allObjects = workPart.Layers.GetAllObjectsOnLayer(layerNumber)
lw.Open()
For Each someObject As NXObject In allObjects
If TypeOf someObject Is NXOpen.Point Then
myPoints.Add(someObject)
End If
If TypeOf someObject Is NXOpen.Arc Then
myArcs.Add(someObject)
End If
Next
'myPoints.Sort
'info dump, not guaranteed to be in any specific order
lw.WriteLine("Point Name,Point X,Point Y,Point Z")
For i = 0 To myPoints.Count - 1
pointXYZ = myPoints(i).Coordinates
pointXYZ = Abs2WCS(pointXYZ)
'pointName = pointObject.Name
Try
pointName = myPoints(i).GetStringAttribute("NM")
Catch
'attribute does not exist
pointName = "<no 'NM' attribute>"
End Try
If i > 1 Then
myDistance = myMeasure.NewDistance(unit1, myPoints(i), myPoints(i - 1))
myAngle = myMeasure.NewAngle(unit1, myPoints(i - 1), myPoints(i - 2), myPoints(i), True)
lw.WriteLine(pointName & "," & Math.Round(pointXYZ.X, 3) & "," & Math.Round(pointXYZ.Y, 3) & "," & Math.Round(pointXYZ.Z, 3) & "," & myDistance.Value & ", " & myAngle.Value)
ElseIf i > 0 Then
myDistance = myMeasure.NewDistance(unit1, myPoints(i), myPoints(i - 1))
lw.WriteLine(pointName & "," & Math.Round(pointXYZ.X, 3) & "," & Math.Round(pointXYZ.Y, 3) & "," & Math.Round(pointXYZ.Z, 3) & "," & myDistance.Value & ",")
Else
lw.WriteLine(pointName & "," & Math.Round(pointXYZ.X, 3) & "," & Math.Round(pointXYZ.Y, 3) & "," & Math.Round(pointXYZ.Z, 3) & ",,")
End If
Next
lw.WriteLine("")
lw.WriteLine("Arc Name, Radius")
For Each arcObject In myArcs
Try
arcName = arcObject.GetStringAttribute("NM")
Catch
'attribute does not exist
arcName = "<no 'NM' attribute>"
End Try
lw.WriteLine(arcName & "," & arcObject.Radius)
Next
lw.Close()
End Sub
'**************************************************************************************************
'function taken from GTAC example
Function Abs2WCS(ByVal inPt As Point3d) As Point3d
Dim pt1(2), pt2(2) As Double
pt1(0) = inPt.X
pt1(1) = inPt.Y
pt1(2) = inPt.Z
ufs.Csys.MapPoint(UFConstants.UF_CSYS_ROOT_COORDS, pt1, UFConstants.UF_CSYS_ROOT_WCS_COORDS, pt2)
Abs2WCS.X = pt2(0)
Abs2WCS.Y = pt2(1)
Abs2WCS.Z = pt2(2)
End Function
'**************************************************************************************************
End Module
www.nxjournaling.com
RE: Extract XYZ points from a Journal file.
RE: Extract XYZ points from a Journal file.
- Attributes
- Feature Attributes
- General
if you don't see the Attributes tab, you've picked only the feature.If you are using point features, it may be better if we change the journal to look for those. This way if you add points later to add a bend in the middle of the pipe, the journal could order the points by the timestamp of the feature and get the order correct (rather than looking for name attributes).
www.nxjournaling.com
RE: Extract XYZ points from a Journal file.
RE: Extract XYZ points from a Journal file.
CODE
CODE
www.nxjournaling.com
RE: Extract XYZ points from a Journal file.