Cyclone3DR / Scripts

Scripts for Leica Cyclone 3DR
32 stars 5 forks source link

Requesting Assistance: Need Faster Point Cloud Chipping Method #7

Closed kelvinAsb closed 3 months ago

kelvinAsb commented 3 months ago

I always use the "separate on both sides" method to chip a point cloud. For example, when I have one point cloud and 4-5 polylines, manually selecting each polyline to chip the cloud becomes time-consuming. Therefore, I hope someone can provide me with "scripts" to automate the process and make chipping the point cloud faster.

Technodigit commented 3 months ago

Hi @kelvinAsb, it is possible to automatize this kind of workflow. Here is an example that select a point cloud and all polylines in the document and extract a sub-cloud for each polylines. It can certainly be adapted depending on your needs.

// Select the first point cloud nammed "Stockpile"
var c = SCloud.FromName("Stockpile")[0];
if(typeof(c) == "undefined")
    throw new Error("Can't find the point cloud");

// Select all polyline available in the project
var polylines = SMultiline.All(SComp.ANY_VISIBILITY);

// Loop over all polylines and extract the sub point cloud inside each polylines and add it to the document.
for(var ii=0; ii<polylines.length; ii++)
{
    var polyline = polylines[ii];
    var dir = SVector.New(0, 0, 1);
    var res = c.Separate(polyline, dir, null, null, SCloud.FILL_IN_ONLY);

    if(res.ErrorCode > 0)
    {
        print("Error with polyline " + polyline.GetName() + " " + res.ErrorCode);
        continue;
    }

    var outCloud = res.InCloud;
    outCloud.SetName(polyline.GetName());
    outCloud.AddToDoc();
}
kelvinAsb commented 3 months ago

hi@Technodigit, I wanted to express my gratitude for providing me with the script I requested. It has been immensely helpful in achieving my desired outcome.

I wanted to inform you that I made a slight adaptation to the script by changing the condition from (res.ErrorCode > 0) to (res.ErrorCode < 0). This modification better aligns with my specific requirements, and I appreciate your understanding.

Once again, thank you for your assistance and prompt response. Your contribution has been invaluable to my project.