Hi, I am a NX10 user. (10.0.3)
I am currently working on a Reverse Engineering task. I need to import the reference data to start a reverse engineering process in Siemens NX 10. My data is a point cloud in .ply format. The cloud, however, has also RGB data associated with each point and I need to import that too.
In other words, I need a coloured point cloud imported in Siemens NX 10, does anyone knows if this is possible and how? Could someone send me a custom-made tool in NXOpen or grip maybe?
Do you know if it is possible in Siemens NX 11 maybe?
Solved! Go to Solution.
Here is a basic journal to read ply data.
1. The ply file is all ascii
2. My ply file is at "c:\cloudpoints\PLY_files\blade.ply". Change this as required
3. The variable I used is called pointvector and is filled with
pointvector(0) is point number
pointvector(1) is point x value
pointvector(2) is point y value
pointvector(3) is pointz value
pointvector(4) is vector i value. This can be your R
pointvector(5) is vector j value. This can be your G
pointvector(6) is vector k value. This can be your B
4. The faces are assumed to consist of three points
I have created the points with a name that is the same as the point number in the ply file. You may not wish to have the journal create all the points. My sample ply file has 882954 points.
I have done nothing with the normal vector which means that the journal dose nothing with your RGB data.
Option Strict Off Imports System Imports System.IO Imports System.Collections Imports System.Windows.Forms Imports NXOpen Imports NXOpen.Utilities Imports NXOpen.UF Module Module1 Dim s As Session = Session.GetSession() Dim ui As UI = ui.GetUI() Dim ufs As UFSession = UFSession.GetUFSession() Dim lw As ListingWindow = s.ListingWindow Dim wp As Part = s.Parts.Work Sub Main() Dim plyfile As String = "c:\cloudpoints\PLY_files\blade.ply" Dim sr As StreamReader = Nothing Dim linestring As String = Nothing Dim testArray() As String Dim vertexcnt As Integer = Nothing Dim facecnt As Integer = Nothing ' read to get vertex numbers and face numbers sr = File.OpenText(plyfile) Do While sr.Peek >= 0 linestring = sr.ReadLine lw.WriteLine(linestring) testArray = Split(linestring, " ", -1) If linestring.Contains("element vertex") Then vertexcnt = CInt(testArray(2)) ElseIf linestring.Contains("element face") Then facecnt = CInt(testArray(2)) ElseIf linestring.Contains("end_header") Then ' linestring = sr.ReadLine Exit Do End If Loop Dim pointvector(vertexcnt - 1, 6) As Double Dim faces(facecnt - 1, 3) As Integer For i As Integer = 0 To vertexcnt - 1 linestring = sr.ReadLine testArray = Split(linestring, " ", -1) pointvector(i, 0) = i pointvector(i, 1) = CDbl(testArray(0)) pointvector(i, 2) = CDbl(testArray(1)) pointvector(i, 3) = CDbl(testArray(2)) pointvector(i, 4) = CDbl(testArray(3)) pointvector(i, 5) = CDbl(testArray(4)) pointvector(i, 6) = CDbl(testArray(5)) Next For i As Integer = 0 To facecnt - 1 linestring = sr.ReadLine testArray = Split(linestring, " ", -1) faces(i, 0) = i faces(i, 1) = CInt(testArray(1)) faces(i, 2) = CInt(testArray(2)) faces(i, 3) = CInt(testArray(3)) Next sr.Close() Dim tmppnt(2) As Double Dim temptag As Tag = Tag.Null Dim point1 As Point = Nothing Dim pntcnt As Integer = Nothing For i As Integer = 0 To vertexcnt - 1 ' create a temporary point tmppnt(0) = pointvector(i, 1) tmppnt(1) = pointvector(i, 2) tmppnt(2) = pointvector(i, 3) ufs.Curve.CreatePoint(tmppnt, temptag) pntcnt = pointvector(i, 0) point1 = NXObjectManager.Get(temptag) point1.SetName(pntcnt.ToString) Next End Sub 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 Module
Thank you for the answer.
Actually, i looked into the tools offered by NX11 and I found out that the "reference point cloud" tool it's exactly what I need, and I'll wait to use that as soon as I'll have access to the 11 version.