Extract points from a point cloud

Extract points from a point cloud

Anonymous
Not applicable
2,521 Views
10 Replies
Message 1 of 11

Extract points from a point cloud

Anonymous
Not applicable

I am using AutoCAd 2016 and need to access and exract a sub-set of points from the point cloud that is attached to the working drawing. I need to let the user click-drag a rectangle and or select few points individually and write out their coordinates to a text file. Is this possible - and if so which API should I use? Thank you!

0 Likes
2,522 Views
10 Replies
Replies (10)
Message 2 of 11

_Tharwat
Advisor
Advisor

Something along this?

 

        [CommandMethod("Test", CommandFlags.Modal)]
        public static void ExtractCoordinatesOfPOintsToTextFile()
        {
            Document Acdoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
            Database dbs = Acdoc.Database;
            Editor edt = Acdoc.Editor;
            PromptSelectionOptions sel = new PromptSelectionOptions();
            TypedValue[] typV = { new TypedValue(0, "POINT") };
            var ss = edt.GetSelection(new SelectionFilter(typV));
            if (ss.Status == PromptStatus.OK)
            {
                SaveFileDialog sv = new SaveFileDialog();
                sv.Title = "Specify Text file name :";
                sv.Filter = "Txt File:|*.txt";
                if (sv.ShowDialog() == DialogResult.OK)
                {
                    using (Transaction trs = dbs.TransactionManager.StartTransaction())
                    {
                        try
                        {
                            StreamWriter writer = new StreamWriter(sv.FileName);
                            foreach (ObjectId id in ss.Value.GetObjectIds())
                            {
                                DBPoint p = (DBPoint)trs.GetObject(id, OpenMode.ForRead);
                                writer.Write(p.Position + Environment.NewLine);
                            }
                            writer.Close();
                        }
                        catch (System.Exception x)
                        {
                            edt.WriteMessage(x.Message);
                        }
                    }
                }
            }
        }
Message 3 of 11

Anonymous
Not applicable

Thanks for the sample code. But that would only select point entities that are par tof the drawing. What I need to do is to select a sub-set of points that are part of a pointcloud that is attached to the working drawing. Any suggestions?

0 Likes
Message 4 of 11

_Tharwat
Advisor
Advisor

Hi.

I have no idea about the pointcloud , is it create with AutoCAD ?

0 Likes
Message 5 of 11

Anonymous
Not applicable

Point clouds are created in Autodesk ReCap from .LAS files. It is attached to AutoCAD by the PCATTACH command.

0 Likes
Message 6 of 11

_Tharwat
Advisor
Advisor

Can you attach a sample drawing to have a look ?

0 Likes
Message 7 of 11

Anonymous
Not applicable

Point clouds are very large. Please download a .las file from following link and convert it to .rcp or .rcs file using Autrodesk ReCap (feree desktop version). The you can attach that point cloud to a drawing using POINTCLOUDATTACH command.

 

http://www.liblas.org/samples/

0 Likes
Message 8 of 11

Mahass
Participant
Participant

Hi

i am trying to start writing à plugin for autocad to make some special tasks on point cloud, 

can anyone tell me how and where to start please? I used to creat autocad plugins in vb and c# under Visual studio.

Please help.

0 Likes
Message 9 of 11

gabrielarchambo
Observer
Observer

I think you need to have a library/sdk (https://www.autodesk.com/developer-network/platform-technologies/reality-solutions-sdk)

 

And to have it you need be a stantard ADN member witch is not free.

 

 

0 Likes
Message 10 of 11

Jkirkla
Contributor
Contributor

For pointclouds, it is best to use ObjectARX, there are more methods and you can accomplish things not possible in .NET. Like spatialfilters or the pointAttributes method which is what could probably be used by the original poster to get coordinates of points.

0 Likes
Message 11 of 11

gleeuwdrent
Advocate
Advocate

Accessing the points in a Point Cloud attached to AutoCAD is not possible with the AutoCAD API as far as I know.

You can build your own .las/laz Point Cloud file reader using this library: https://github.com/shintadono/laszip.net

 

Then you can access the points of the file directly without converting it to a .rcs file.

0 Likes