# Point Cloud Plane Detection using RANSAC

**URL:** <https://forum.dynamobim.com/t/point-cloud-plane-detection-using-ransac/70736>\
**Category:** Share\
**Tags:** geometry, developers\
**Created:** [November 24, 2021, 9:12pm UTC](https://forum.dynamobim.com/t/point-cloud-plane-detection-using-ransac/70736 "2021-11-24T21:12:46Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ewan\_Opie](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/ewan_opie/32/77070_2.png) [@Ewan\_Opie](https://forum.dynamobim.com/u/Ewan_Opie)\
**Post date:** [November 24, 2021, 9:12pm UTC](https://forum.dynamobim.com/t/point-cloud-plane-detection-using-ransac/70736/1 "2021-11-24T21:12:46Z")

</div>

Hi All,

Just thought I would chuck this out there for you all to experiment with, as I am looking to inlcude revised point cloud functionality in my next ❄ Sastrugi Package ❄ update 🙂

This graph takes an input XYZ list of pointcloud points, and sorts them into groups based on the RASAC algorythm, as to define specific planes within the point cloud. This can be handy when defining floors, ceiling, walls, columns, etc, so I am very excited as I bundle some nodes together that reflect those capabilities.

**Note:**  
**This graph and its code will only function in Dynamo versions able to run cPython3 and have external python packages installed (as it uses numpy)**  
(_I have been playing around in Dynamo Core 2.10 in this instance._)

Enjoy 🕶

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/6/061f096b1983a8bf1bd5ee93eab456647adc69cb.png)

[Pointcloud Plane Detection using RANSAC.dyn](https://forum.dynamobim.com/uploads/short-url/2WtiGtMzpc99L2sb9KP31Zsj0iu.dyn) (27.3 KB)

FYI @Daan

EDIT: I have just tweaked this so it works in IronPython with no package imports from numpy 🕶  
This coding thing is awesome! 🤘 Its crazy how much the last 18 months of intense Dynamo development has improved my understanding of things.  
I’ll post an example of this in action using some of the other Sastrugi nodes in Revit tomorrow as my software is being difficult just now.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/3/43a572f0bb878710eded0e8912d0b4f428f47d69.png)

---

<div class="post-metadata">

**Author:** ![Marcel\_Rijsmus](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/marcel_rijsmus/32/8539_2.png) [@Marcel\_Rijsmus](https://forum.dynamobim.com/u/Marcel_Rijsmus)\
**Post date:** [November 24, 2021, 9:44pm UTC](https://forum.dynamobim.com/t/point-cloud-plane-detection-using-ransac/70736/2 "2021-11-24T21:44:13Z")

</div>

Nice one kiwi 🙂

---

<div class="post-metadata">

**Author:** ![WrightEngineering](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/wrightengineering/32/115676_2.png) [@WrightEngineering](https://forum.dynamobim.com/u/WrightEngineering)\
**Post date:** [November 25, 2021, 3:21am UTC](https://forum.dynamobim.com/t/point-cloud-plane-detection-using-ransac/70736/3 "2021-11-25T03:21:12Z")

</div>

Woah! Been following your posts for awhile. This one is really impressive and incredibly useful.

---

<div class="post-metadata">

**Author:** ![RMohareb](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/rmohareb/32/120534_2.png) [@RMohareb](https://forum.dynamobim.com/u/RMohareb)\
**Post date:** [December 1, 2021, 10:13am UTC](https://forum.dynamobim.com/t/point-cloud-plane-detection-using-ransac/70736/4 "2021-12-01T10:13:29Z")

</div>

Create polygon and surface after Point Cloud Plane Detection  
🙂

> [@Alpha Shape proplem (Draw outer line around the outside point Cloud at the same plane by ignoring any points that would fall inside.)](https://forum.dynamobim.com/t/alpha-shape-proplem-draw-outer-line-around-the-outside-point-cloud-at-the-same-plane-by-ignoring-any-points-that-would-fall-inside/70950):
>
> Draw outer line around the outside points by ignoring any points that would fall inside. I used Alpha Shape algorethem [alphashape · PyPI](https://pypi.org/project/alphashape/) by install alphashape in Python3 ![image|638x499](upload://8JnHvCiJDujl [Pointcloud Plane Detection using RANSAC\_Alpha Shape.dyn](https://forum.dynamobim.com/uploads/short-url/yA8oX7K0ZGut7J4ntcOcZkHBrgB.dyn) (103.1 KB) NwjwfcAuhGcpyVW.png) First select point cloud form revit project by using @Julien_Benoit1 Julien Benoit python script Second use [point-cloud-plane-detection-using-ransac](https://forum.dynamobim.com/t/point-cloud-plane-detection-using-ransac/70736) @Ewan_Opie to detect…

---

<div class="post-metadata">

**Author:** ![Daan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/daan/32/82246_2.png) [@Daan](https://forum.dynamobim.com/u/Daan)\
**Post date:** [December 3, 2021, 2:30pm UTC](https://forum.dynamobim.com/t/point-cloud-plane-detection-using-ransac/70736/5 "2021-12-03T14:30:21Z")

</div>

@Ewan_Opie could you share your new Python RANSAC Code which doesnt need NumPy?

---

<div class="post-metadata">

**Author:** ![diegorodriguesK33MF](https://avatars.discourse-cdn.com/v4/letter/d/838e76/32.png) [@diegorodriguesK33MF](https://forum.dynamobim.com/u/diegorodriguesK33MF)\
**Post date:** [June 3, 2022, 11:52pm UTC](https://forum.dynamobim.com/t/point-cloud-plane-detection-using-ransac/70736/6 "2022-06-03T23:52:33Z")

</div>

Hi folks, im looking to create one line on the centerline of pointcloud pipe but when i try to use any examples of sastrugi package they return null everytime.

Can anyone explain to me how to avoid this?

Thanks in advance (i’m already see the “How to Determine Centreline of a Pipe from Point Cloud” but im still getting the error when i try to select the points.

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![Ewan\_Opie](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/ewan_opie/32/77070_2.png) [@Ewan\_Opie](https://forum.dynamobim.com/u/Ewan_Opie)\
**Post date:** [June 4, 2022, 2:31am UTC](https://forum.dynamobim.com/t/point-cloud-plane-detection-using-ransac/70736/7 "2022-06-04T02:31:16Z")

</div>

Hi @diegorodriguesK33MF

Can you post your graph, and point cloud sample for trouble shooting?

There may be an issue with the projection of the clipping box which selects the points. If so, I can test this on Tuesday next week.

---

<div class="post-metadata">

**Author:** ![Ewan\_Opie](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/ewan_opie/32/77070_2.png) [@Ewan\_Opie](https://forum.dynamobim.com/u/Ewan_Opie)\
**Post date:** [June 4, 2022, 2:31am UTC](https://forum.dynamobim.com/t/point-cloud-plane-detection-using-ransac/70736/8 "2022-06-04T02:31:56Z")

</div>

> [@Daan](#):
>
> could you share your new Python RANSAC Code which doesnt need NumPy?

I’ll have a look in my archives in Tuesday 😉

---

<div class="post-metadata">

**Author:** ![Ewan\_Opie](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/ewan_opie/32/77070_2.png) [@Ewan\_Opie](https://forum.dynamobim.com/u/Ewan_Opie)\
**Post date:** [June 6, 2022, 5:07am UTC](https://forum.dynamobim.com/t/point-cloud-plane-detection-using-ransac/70736/9 "2022-06-06T05:07:06Z")

</div>

So I found it to #share . 👍

There are a few minor hoops to jump through to format your input point data, but hopefully everything is explained well enough.

 ![Ransac IronPython Share](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/2/d2225a499f76a6305c508f326a2840f3d09f8c62.png)

[IronPython RANSAC Plane Detection Share.dyn](https://forum.dynamobim.com/uploads/short-url/pWY4Ifrp3FuEcfw4IZyApK4YcbT.dyn) (39.3 KB)

---

<div class="post-metadata">

**Author:** ![diegorodriguesK33MF](https://avatars.discourse-cdn.com/v4/letter/d/838e76/32.png) [@diegorodriguesK33MF](https://forum.dynamobim.com/u/diegorodriguesK33MF)\
**Post date:** [June 6, 2022, 12:52pm UTC](https://forum.dynamobim.com/t/point-cloud-plane-detection-using-ransac/70736/10 "2022-06-06T12:52:23Z")

</div>

Hi Ewan, im stuck on this problem at the moment, when i use the “Select points by region” im getting no point info at all. I’ve see that the problem has ocurred with other people but i cant figure how to solve this by myself.

Im from Brazil and here we use meters and mm as units (not feet), could you helpe with this?

Ps : my script only consists in two selection points that are taken and after the script creates one line using bestfit. (really simple, just to help me to save some time on point cloud modelling)

Best Regards

Here is the sample rcp : (im using shared coordinates on revit)

> **[Samples.rar](https://drive.google.com/file/d/145fQXtbx5lISjF56Gzeo0wL8bfaMcEeB/view?usp=sharing)**
>
> Google Drive file.

![error](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/9/998ef7ceb2d3bd1c0da911a788b5c2a91f1e92f6.png)

---

<div class="post-metadata">

**Author:** ![Ewan\_Opie](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/ewan_opie/32/77070_2.png) [@Ewan\_Opie](https://forum.dynamobim.com/u/Ewan_Opie)\
**Post date:** [June 7, 2022, 7:14am UTC](https://forum.dynamobim.com/t/point-cloud-plane-detection-using-ransac/70736/11 "2022-06-07T07:14:27Z")

</div>

Hi @diegorodriguesK33MF

I have made a minor revision to the code and updated the **❄Sastrugi Package​:snowflake:** to v2.0.2 🙂

![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/2/d288799126e3c2a1094ec6e2070b54aa9fa59e35.png)

The nodes for Pointcloud selection look to have had a naming conflict within them that may have been preventing the output, and I have also fixed a filter-box issue that would prevent the sample being taken from within the point cloud.

Can you check if this fix solves your issue?

I cannot look into your sample data as it is too, large.  
Can you segment the cloud in the area you are looking at and provide an updated link?

I will be re-writing my package for the new cPython environment when I get some time, which should help with some of these issues, as my knowledge of how to code effectively since first starting the package has increased tremendously.

---

<div class="post-metadata">

**Author:** ![diegorodriguesK33MF](https://avatars.discourse-cdn.com/v4/letter/d/838e76/32.png) [@diegorodriguesK33MF](https://forum.dynamobim.com/u/diegorodriguesK33MF)\
**Post date:** [June 7, 2022, 12:03pm UTC](https://forum.dynamobim.com/t/point-cloud-plane-detection-using-ransac/70736/12 "2022-06-07T12:03:39Z")

</div>

Thanks for the update Ewan, unfortunately im still getting no points, i’ve tried using a non georeferenced pointcloud on center to center and even with this the nodes doesn’t give me info (the list keeping getting null).

Here are the link containing the new sample (an unified small piece of the area)

> **[Sample2.rar](https://drive.google.com/file/d/1HKWcGU_q6mtbzEAJ19KZIMilfGcEJ--_/view?usp=sharing)**
>
> Google Drive file.

Thanks again for your help

---

<div class="post-metadata">

**Author:** ![Ewan\_Opie](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/ewan_opie/32/77070_2.png) [@Ewan\_Opie](https://forum.dynamobim.com/u/Ewan_Opie)\
**Post date:** [June 7, 2022, 11:22pm UTC](https://forum.dynamobim.com/t/point-cloud-plane-detection-using-ransac/70736/13 "2022-06-07T23:22:12Z")

</div>

I have had a look at your cloud data, seems to return points.  
Can you post a screenshot of the results of you running the attached graph?

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/8/8878d9fe16bb1e7b2930fe04c684554f54966c59.jpeg)  
[SastrugiTest.dyn](https://forum.dynamobim.com/uploads/short-url/9BCkkOABdBt36bkBjAO5W3XyKxk.dyn) (20.6 KB)

---

<div class="post-metadata">

**Author:** ![Ewan\_Opie](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/ewan_opie/32/77070_2.png) [@Ewan\_Opie](https://forum.dynamobim.com/u/Ewan_Opie)\
**Post date:** [June 8, 2022, 7:20am UTC](https://forum.dynamobim.com/t/point-cloud-plane-detection-using-ransac/70736/14 "2022-06-08T07:20:37Z")

</div>

@diegorodriguesK33MF Can you check if using this fix resolves your issue. It has to do with the extraction of document UnitType’s in later versions of Revit.

> [@Trouble with Python script with Sastrugi Package](https://forum.dynamobim.com/t/trouble-with-python-script-with-sastrugi-package/72854/16):
>
> Ok, so the issue is the Revit versioning and depreciated API functions for establishing Document UnitTypes. The below .dyn should be copied into the Sastrugi package folder overwriting the version included in the 2.0.2 release. This should be the only node affected. [\_\_Pointcloud\_Select\_Points\_By\_Region.dyf](https://forum.dynamobim.com/uploads/short-url/4XEvTrXBwwhWcSUCdHZXgIdxaVy.dyf) (262.5 KB) I will roll this change into a future release, but for now this ‘patch’ solution should be used.

---

<div class="post-metadata">

**Author:** ![diegorodriguesK33MF](https://avatars.discourse-cdn.com/v4/letter/d/838e76/32.png) [@diegorodriguesK33MF](https://forum.dynamobim.com/u/diegorodriguesK33MF)\
**Post date:** [June 8, 2022, 5:44pm UTC](https://forum.dynamobim.com/t/point-cloud-plane-detection-using-ransac/70736/15 "2022-06-08T17:44:24Z")

</div>

> [@Trouble with Python script with Sastrugi Package](https://forum.dynamobim.com/t/trouble-with-python-script-with-sastrugi-package/72854/16):
>
> o

Hi @Ewan_Opie Ewan, i’ve tried everything (change my units in project, use other pointclouds, use other versions of revit and test in another computer aswell) with no success, bellow is the image of the sastrugitest.dyn when i run it.

I have tried to use the old versions of the package on revit 2020,2021 and the error persists, maybe is something related of my local language or units i don’t know. To run the package i need to use other thing than just download the node inside dynamo? (any dependencies or something).

Thanks and sorry to disturb you with that.

 ![ERRO2](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/c/9cc71b08bc3decc9b29aa53ea0d55b3c0afefc95.png)

---

<div class="post-metadata">

**Author:** ![soe78267](https://avatars.discourse-cdn.com/v4/letter/s/58956e/32.png) [@soe78267](https://forum.dynamobim.com/u/soe78267)\
**Post date:** [October 30, 2023, 6:27am UTC](https://forum.dynamobim.com/t/point-cloud-plane-detection-using-ransac/70736/16 "2023-10-30T06:27:11Z")

</div>

![Screenshot (155)](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/f/6f74a0a3d82991f4530a807571ba18d0396e596f.png)

Hello, thank you for your contribution, Mr. Ewan Opie! I am a new to Dynamo. I used the Iron Python RANSAC Plane Detection Share. Dyn on my scanned model and the output is as shown in the above photo. Could someone please tell me what is wrong with my case and how to improve this if possible?  
I think it is because of low quality of my point cloud model.  
I would appreciate and would be great help a lot to me if anyone can discuss for this.

---

<div class="post-metadata">

**Author:** ![Ewan\_Opie](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/ewan_opie/32/77070_2.png) [@Ewan\_Opie](https://forum.dynamobim.com/u/Ewan_Opie)\
**Post date:** [October 30, 2023, 7:05am UTC](https://forum.dynamobim.com/t/point-cloud-plane-detection-using-ransac/70736/17 "2023-10-30T07:05:48Z")

</div>

Hi @soe78267  
Great that you are dabbling into Dynamo. 👍  
When using the RANSAC node, the quality and quantity of your input data can affect the results.  
A few questions:

- How many points are you inputting?
- How many planes would you expect to be output?
- What are your overall goals for your workflow?
- Can you show your graph configuration?

Cheers 🙂

---

<div class="post-metadata">

**Author:** ![soe78267](https://avatars.discourse-cdn.com/v4/letter/s/58956e/32.png) [@soe78267](https://forum.dynamobim.com/u/soe78267)\
**Post date:** [November 8, 2023, 4:13am UTC](https://forum.dynamobim.com/t/point-cloud-plane-detection-using-ransac/70736/18 "2023-11-08T04:13:44Z")

</div>

@Ewan_Opie  
Thank you for your prompt reply!

. My point cloud model has 740,331 vertices.  
. I would like to detect all of my walls, floor and roof.  
. My overall goal is to automatically create the surfaces such as floor after detecting them.  
. I attached my graph configuration as below.

Always appreciate to your kindly support

 ![IronPython RANSAC Plane Detection Share_-Y Lab meeting room_2023-11-08_01-12-57](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/c/dc3990f7ad549e720933f7b8258546cf8441c022.png)
