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

Extract points from a point cloud

10 REPLIES 10
Reply
Message 1 of 11
Anonymous
2082 Views, 10 Replies

Extract points from a point cloud

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!

Tags (2)
10 REPLIES 10
Message 2 of 11
_Tharwat
in reply to: Anonymous

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
in reply to: _Tharwat

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?

Message 4 of 11
_Tharwat
in reply to: Anonymous

Hi.

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

Message 5 of 11
Anonymous
in reply to: _Tharwat

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

Message 6 of 11
_Tharwat
in reply to: Anonymous

Can you attach a sample drawing to have a look ?

Message 7 of 11
Anonymous
in reply to: _Tharwat

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/

Message 8 of 11
Mahass
in reply to: Anonymous

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.

Message 9 of 11
gabrielarchambo
in reply to: Mahass

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.

 

 

Message 10 of 11
Jkirkla
in reply to: Anonymous

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.

Message 11 of 11
gleeuwdrent
in reply to: Anonymous

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.

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

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report