×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Extract XYZ points from a Journal file.
2

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!
 

RE: Extract XYZ points from a Journal file.

Have you looked at the Routing modules available with NX?  They already provide this sort of capability, and much more:

http://www.plm.automation.siemens.com/en_us/Images/4181_tcm1023-47161.pdf

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.

(OP)
Yes, we do not have that license.

RE: Extract XYZ points from a Journal file.

What distinguishes the points that you want to extract this information from? Is it all the points in the file, all the points on a certain layer(s), all points in a certain group, all points of a certain color, etc? Have you created arcs to represent the bends, and if so how do you distinguish those (layer, color, name, etc)?

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 Know there is a GRIP program out there someplace that will do what you need.
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.

Here is some code that might get you started. It looks on a specified layer for all the arc and point objects and returns information (point coordinates, arc radii). It seems to return the objects in created order, which may not be desirable. To determine what info goes with what object, I added some code to look for an attribute named NM (originally it was named NAME, but I didn't want to confuse that with the actual name of the object). By giving each object an attribute, you can also add 'smart notes' to your drawing to label each point and arc (notes that reference the attribute value and change automatically when the attribute value changes).

 

RE: Extract XYZ points from a Journal file.

Is there any way to have this info automatically placed in an .xls file and delimited instead of the information window?

RE: Extract XYZ points from a Journal file.

There are a few options here.
  1. You'll notice that the output to the listing window is separated by commas (aka comma separated values). You can do a File -> Save As... from the listing window then change the file extension from .txt to .csv and open the file directly in Excel.
  2. You can add code to output a .csv file directly, bypassing the listing window entirely.
  3. You can use a database connection object to export information to an existing database (Excel can accept such a connection). I have done this with an old database (Lotus Approach) so I know the method works, but I have never used it to connect to Excel, though I'm 95% sure it could be made to work.
  4. If you have some form of Microsoft Visual Studio installed (even the free 'express' version should work), you can link in the Microsoft office libraries and work with Excel's object model directly (plain vanilla NX journaling is not linked to these libraries).

RE: Extract XYZ points from a Journal file.

If the data was exported directly to a .csv file, could it go directly to an excel file connected to the part currently being worked in. As an example, if I had a spreadsheet connected to the part file that was set up to delimit by commas, could i send these values directly to that spreadsheet?

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.

(OP)
Cowski Your program is great! I have one request - make that a couple.  1) Everytime I execute the program I get "<no 'NM' attribute>", I'm having trouble assigning the NM attribute. 2) How do I obtain the distance from PTA 2 PTB & PTB 2 PTC, etc. 3) And is it possible to obtain the included angle of ABC, BCD, etc.

Man if you can answer this I owe you a beer!!

RE: Extract XYZ points from a Journal file.

2
snakemaster,
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

Option Strict Off  
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.

(OP)
Cowski - It works great (let me know where to ship the beer to) and the nxjournaling site helps as well. The problem I still having is I am not able to get it to read the attributes I have assigned to the points (that are part of the drawing) and reading the arcs (which are part of its component). The arcs I can live without but the rest of it is sweet!!

RE: Extract XYZ points from a Journal file.

Are you using "dumb" points, or point features? In its current form, the journal looks for attributes assigned to point objects; if you are assigning the attributes to the feature, it will not be found. In the edit properties dialog box, you should see 3 tabs:
  • 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.

(OP)
I was using point features, dumb points are fine. I have changed the accuracy on the xyz coords to 1 place.  How do I change the accuracy of the angle and lengths to 1 place?

RE: Extract XYZ points from a Journal file.

One way to do it is to change

CODE

myDistance.Value
to

CODE

myDistance.Value.ToString("0.#;-0.#")
and do the same for the angle variable.

www.nxjournaling.com

RE: Extract XYZ points from a Journal file.

(OP)
Since you don't want to drink with me smile, I guess I just going to have to make a donation to this site. Just to say thanks, is not enough but thanks anyways!!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources