.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Point Cloud Crop VBNET

1 REPLY 1
Reply
Message 1 of 2
Anonymous
691 Views, 1 Reply

Point Cloud Crop VBNET

New to the forum!

 

I'm working on tailoring Madhukar Moogala's excellent code on point cloud cropping to fit some specific needs. You can find his code here:

 

https://adndevblog.typepad.com/autocad/2017/02/how-to-crop-a-point-cloud-using-api.html

 

I've got the code transcribed to VB.NET and am able to verify that it is performing the crop operation. However, I am having difficulty understanding how to meaningfully adjust the crop area. Right now I'm just trying to crop a rectangle out, but when I run the code, my entire cloud disappears because it is cropping somewhere outside the bounds of my point cloud. I know it's cropping because if I invert the crop, my cloud re-appears. I've made sure my point cloud is around the origin of 0,0,0 similar to the example, but still cannot get it to crop anything within the bound of my cloud. I think I am not understanding the logic of defining a plane and the crop vertices.

 

From what I understanding from reading the documentation , a point cloud crop needs a CropPlane and Vertices. Here's the key part of Madhukar's code converted to VBNET with the arguments coded into the function for simplification:

 

        Public Shared Function addcropping(ByVal pointcloud As PointCloudEx) As ErrorStatus

            Dim crop As PointCloudCrop = PointCloudCrop.Create(IntPtr.Zero)
            Dim points As Point3dCollection = New Point3dCollection()

            Dim pt1 As New Point3d(-7, 12, 0)
            Dim pt2 As New Point3d(-4, 9, 0)

            points.Add(pt1) 'add points to the point3dCollection
            points.Add(pt2)

            'confused as to why he only supplied two points when the crop type is rectangle. Documentation appears to call for 5: (1,2,3,4, and 1st again)
            crop.Vertices = points

            Dim norm As Vector3d = New Vector3d(0, 1, 0)

            'I understand plane to form an XY plane because both pt1 (-7,12,0) and norm (0,1,0) have a value of 0 for the Z axis.
' 'maybe this is where I'm wrong in my thinking? Dim cropPlane As Plane = New Plane(pt1, norm) crop.CropPlane = cropPlane crop.CropType = PointCloudCropType.Rectangular crop.Inside = True crop.Inverted = False pointcloud.addCroppingBoundary(crop) Return ErrorStatus.OK End Function

By changing the values for pt1 and pt2, I am unable to intelligently "move" the cropped area into my point cloud. In my mind, the above code should cut out a rectangle looking at the cloud from the top down. But I'm obviously errant in my thinking because it seems that no matter what I change those values to, I can't get the crop to touch my cloud. Could someone explain to me how the plane and points in the plane work? Has anyone been able to implement madhukar's code? Any help is appreciated. Been stuck on this for a while. 

 

 

 

 

 

 

 

 

 

1 REPLY 1
Message 2 of 2
yt1
Community Visitor
in reply to: Anonymous

Hello, I know this topic is very old, but I stumbled upon it while having the same problem of trying to crop point clouds using code. I had the same problem as you but I was using C# .NET. The problem with the crop being way off is most likely due to the units of measurement in the rcs file not matching the units of Autocad. So I did .NativeExtents() and .GeomExtents(), I found my native extents (native dimensions of pointcloud) and had a number like (100,50,25), meanwhile my geomextents where something like (10000,5000,2500), this was because the units of the rcs were in meters and my autocad was in millimeters. Once I changed autocad to meters, I was able to crop the pointcloud properly using values from autocad.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Autodesk Design & Make Report