Browse a point cloud

Browse a point cloud

Anonymous
Not applicable
524 Views
2 Replies
Message 1 of 3

Browse a point cloud

Anonymous
Not applicable

Hi, 

 

I would like to browse a point cloud in order to retrieve coordinates of each points. 

 'Déclaration de l'éxécute
        Dim nuage As PointCloudType
        Dim nuageinst As PointCloudInstance
        'Dim nuagecollect As PointCollection

        nuage = PointCloudType.Create(doc, "rcs", "C:\nuage.rcs")
        nuageinst = PointCloudInstance.Create(doc, nuage.Id, Transform.Identity)

        t.Commit()

        Dim boundingBox As BoundingBoxXYZ = nuageinst.BoundingBox(Nothing)

        Dim planes As New List(Of Plane)()
        Dim midpoint As XYZ = (boundingBox.Min + boundingBox.Max) / 2.0

        ' X boundaries 
        planes.Add(uidoc.Application.Application.Create.NewPlane(XYZ.BasisX, boundingBox.Min))
        planes.Add(uidoc.Application.Application.Create.NewPlane(-XYZ.BasisX, midpoint))

        ' Y boundaries 
        planes.Add(uidoc.Application.Application.Create.NewPlane(XYZ.BasisY, boundingBox.Min))
        planes.Add(uidoc.Application.Application.Create.NewPlane(-XYZ.BasisY, midpoint))

        ' Z boundaries 
        planes.Add(uidoc.Application.Application.Create.NewPlane(XYZ.BasisZ, boundingBox.Min))
        planes.Add(uidoc.Application.Application.Create.NewPlane(-XYZ.BasisZ, midpoint))

        ' Create filter 
        Dim filter As PointCloudFilter = PointCloudFilterFactory.CreateMultiPlaneFilter(planes)

        Dim tr As New Transaction(doc)
        tr.Start("Balayage")

        Using fichier As New StreamWriter("C:\points.txt", False)
            ' read points by iteration
            Dim averageDistance As Double = 0.0001
            Dim points As PointCollection = nuageinst.GetPoints(filter, averageDistance, 100000)
            ' Get points.  Number of points is determined by the needs of the client 
            For Each point As CloudPoint In points
                ' Process each point 
                Dim color As System.Drawing.Color = System.Drawing.ColorTranslator.FromWin32(point.Color)
                Dim pointDescription As [String] = [String].Format("({0}, {1}, {2}, {3}", point.X, point.Y, point.Z, color.ToString())
                MsgBox(pointDescription)
            Next
            fichier.WriteLine(points.Count.ToString)
            fichier.Close()
        End Using
        tr.Commit()

 The file "points.txt " shows 0 and i don't undestand why. 

 

Thanks, 

 

0 Likes
525 Views
2 Replies
Replies (2)
Message 2 of 3

jeremytammik
Autodesk
Autodesk

I would suggest executing your code in the Visual Studio debugger.

 

Then you will be able to see what is happening line by line.

 

Just looking at it with my poor human eyes does not tell me much.

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 3

Anonymous
Not applicable

Thank you Jeremy,

 

Indeed, I "debug" like you say and I had an error with the filter.

 

Now, it works !!!

 

Thanks again

0 Likes