# How to prune duplicate points with tolerance in python?

**URL:** <https://forum.dynamobim.com/t/how-to-prune-duplicate-points-with-tolerance-in-python/78206>\
**Category:** Revit\
**Tags:** python\
**Created:** [June 30, 2022, 12:51pm UTC](https://forum.dynamobim.com/t/how-to-prune-duplicate-points-with-tolerance-in-python/78206 "2022-06-30T12:51:28Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![newshunhk](https://avatars.discourse-cdn.com/v4/letter/n/3bc359/32.png) [@newshunhk](https://forum.dynamobim.com/u/newshunhk)\
**Post date:** [June 30, 2022, 12:51pm UTC](https://forum.dynamobim.com/t/how-to-prune-duplicate-points-with-tolerance-in-python/78206/1 "2022-06-30T12:51:28Z")

</div>

Is there any revitapi method to achieve this?  
or can be achieved by this?

```auto
import numpy as np
from scipy.spatial import cKDTree

```

in cpython?

---

<div class="post-metadata">

**Author:** ![Draxl\_Andreas](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/draxl_andreas/32/145744_2.png) [@Draxl\_Andreas](https://forum.dynamobim.com/u/Draxl_Andreas)\
**Post date:** [June 30, 2022, 12:59pm UTC](https://forum.dynamobim.com/t/how-to-prune-duplicate-points-with-tolerance-in-python/78206/2 "2022-06-30T12:59:45Z")

</div>

@newshunhk ,

Do you have already installed the module? - numpy

I struggle to install Sympy correctly 😕

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [June 30, 2022, 1:44pm UTC](https://forum.dynamobim.com/t/how-to-prune-duplicate-points-with-tolerance-in-python/78206/3 "2022-06-30T13:44:23Z")

</div>

This should work: [Dynamo Dictionary](https://dictionary.dynamobim.com/#/Geometry/Point/Action/PruneDuplicates)

In python that’d be something like  
prunedPoints = Point.PruneDuplicates(originalPnts, 0.1)

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [June 30, 2022, 1:46pm UTC](https://forum.dynamobim.com/t/how-to-prune-duplicate-points-with-tolerance-in-python/78206/4 "2022-06-30T13:46:29Z")

</div>

> [@Draxl\_Andreas](#):
>
> I struggle to install Sympy correctly

Assuming you’re using CPython3, and have followed the instructions here: [Customizing Dynamo's Python 3 installation · DynamoDS/Dynamo Wiki · GitHub](https://github.com/DynamoDS/Dynamo/wiki/Customizing-Dynamo's-Python-3-installation)

Which step are you stuck on?

---

<div class="post-metadata">

**Author:** ![Draxl\_Andreas](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/draxl_andreas/32/145744_2.png) [@Draxl\_Andreas](https://forum.dynamobim.com/u/Draxl_Andreas)\
**Post date:** [June 30, 2022, 1:58pm UTC](https://forum.dynamobim.com/t/how-to-prune-duplicate-points-with-tolerance-in-python/78206/5 "2022-06-30T13:58:32Z")

</div>

![2022-06-30_15h57_16](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/4/240a048a97aa4176d990dc34de5acee39065a16c.png)

when i run my path it is wrong, i think i don`t have this window  
 ![2022-06-30_13h39_08](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/b/0b33fd0740b160034d6cd0654704b435b9f7658b.png)

 ![2022-06-30_16h10_33](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/e/5effb90eeb4f330a1080d5298e4aac07e631bc48.png)

---

<div class="post-metadata">

**Author:** ![newshunhk](https://avatars.discourse-cdn.com/v4/letter/n/3bc359/32.png) [@newshunhk](https://forum.dynamobim.com/u/newshunhk)\
**Post date:** [June 30, 2022, 2:08pm UTC](https://forum.dynamobim.com/t/how-to-prune-duplicate-points-with-tolerance-in-python/78206/6 "2022-06-30T14:08:52Z")

</div>

Hi, I decide to code it without dynamo

---

<div class="post-metadata">

**Author:** ![newshunhk](https://avatars.discourse-cdn.com/v4/letter/n/3bc359/32.png) [@newshunhk](https://forum.dynamobim.com/u/newshunhk)\
**Post date:** [June 30, 2022, 2:09pm UTC](https://forum.dynamobim.com/t/how-to-prune-duplicate-points-with-tolerance-in-python/78206/7 "2022-06-30T14:09:27Z")

</div>

no ☹  
I can’t import numpy yet ☹

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [June 30, 2022, 2:21pm UTC](https://forum.dynamobim.com/t/how-to-prune-duplicate-points-with-tolerance-in-python/78206/8 "2022-06-30T14:21:11Z")

</div>

Directly placing modules is likely going to cause some issues; best to utilize the pypi tool.

Can you show what happens when you open the start menu and search for ‘cmd’ ? GIF or screen recording would be best.

---

<div class="post-metadata">

**Author:** ![Draxl\_Andreas](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/draxl_andreas/32/145744_2.png) [@Draxl\_Andreas](https://forum.dynamobim.com/u/Draxl_Andreas)\
**Post date:** [June 30, 2022, 2:27pm UTC](https://forum.dynamobim.com/t/how-to-prune-duplicate-points-with-tolerance-in-python/78206/9 "2022-06-30T14:27:26Z")

</div>

![2022-06-30_16h25_59](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/a/aacbdd7a807f6239a186adec1516781e6089412f.gif)

![2022-06-30_16h26_30](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/6/7/67b5c16bea9ad1a10e9c931eef485616d7d5ba44.png)

```auto
python38.zip
.

Uncomment to run site.main() automatically
import site

```

![2022-06-30_16h27_13](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/8/0/803c0421a69669eca650340ab7d81d673a314b8f.png)

in the discription the use a other window

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [June 30, 2022, 2:29pm UTC](https://forum.dynamobim.com/t/how-to-prune-duplicate-points-with-tolerance-in-python/78206/10 "2022-06-30T14:29:27Z")

</div>

This will be a lot more work to manage as not only will you need to get these files onto your system following the link I posted above, but you’ll also have to manage the deployment thereof.

The Revit API does have the capability to compare XYZs in terms of “almost being equal to”, with this method: [IsAlmostEqualTo Method (XYZ, Double)](https://www.revitapidocs.com/2023/81a72471-bfa6-18ec-db83-911a49c3f4e8.htm). So you can pop a point out, test all other points in the list for almost being equal and remove them from the list if they return true, otherwise continue on. Repeat that list until the original list of XYZ values is 0.

Not the most effective by any means (a means of grouping the XYZ values into smaller groups would help), but it’d do the trick.

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [June 30, 2022, 2:30pm UTC](https://forum.dynamobim.com/t/how-to-prune-duplicate-points-with-tolerance-in-python/78206/12 "2022-06-30T14:30:54Z")

</div>

I may be seeing this wrong, but you appear to be working in a visual studio window instead of the windows command prompt; not sure that’ll do the trick as it’d configure your development environment but perhaps not the Dynamo one.

---

<div class="post-metadata">

**Author:** ![Draxl\_Andreas](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/draxl_andreas/32/145744_2.png) [@Draxl\_Andreas](https://forum.dynamobim.com/u/Draxl_Andreas)\
**Post date:** [June 30, 2022, 2:32pm UTC](https://forum.dynamobim.com/t/how-to-prune-duplicate-points-with-tolerance-in-python/78206/13 "2022-06-30T14:32:20Z")

</div>

@jacob.small , i have no windows comment prompt … can i simple install it?

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [June 30, 2022, 2:34pm UTC](https://forum.dynamobim.com/t/how-to-prune-duplicate-points-with-tolerance-in-python/78206/14 "2022-06-30T14:34:19Z")

</div>

If you open the start menu and type “cmd” what do you see for options? Sadly I’ve got a bit of a localization handicap here.

---

<div class="post-metadata">

**Author:** ![Draxl\_Andreas](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/draxl_andreas/32/145744_2.png) [@Draxl\_Andreas](https://forum.dynamobim.com/u/Draxl_Andreas)\
**Post date:** [June 30, 2022, 2:37pm UTC](https://forum.dynamobim.com/t/how-to-prune-duplicate-points-with-tolerance-in-python/78206/15 "2022-06-30T14:37:46Z")

</div>

![2022-06-30_16h37_14](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/3/1/31837ed9b319b488bea826401749f39ba7565dba.png)

i have just these, is there a shortcut maybe? or via taskmanager? @jacob.small
