# Collecting the perimeter curves of a Toposolid

**URL:** <https://forum.dynamobim.com/t/collecting-the-perimeter-curves-of-a-toposolid/94913>\
**Category:** Geometry\
**Created:** [October 25, 2023, 9:22pm UTC](https://forum.dynamobim.com/t/collecting-the-perimeter-curves-of-a-toposolid/94913 "2023-10-25T21:22:36Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pedehh](https://avatars.discourse-cdn.com/v4/letter/p/e0b2c6/32.png) [@Pedehh](https://forum.dynamobim.com/u/Pedehh)\
**Post date:** [October 25, 2023, 9:22pm UTC](https://forum.dynamobim.com/t/collecting-the-perimeter-curves-of-a-toposolid/94913/1 "2023-10-25T21:22:36Z")

</div>

Hello

Im trying to collect the perimeter curves of a toposolid.  
I got as far as collecting all the edgecurves on the many surfaces the toposolid is formed by, anyone knows a great method for filtering that list, so i get only the curves on the outer edge of the toposolid?

---

<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:** [October 25, 2023, 11:32pm UTC](https://forum.dynamobim.com/t/collecting-the-perimeter-curves-of-a-toposolid/94913/2 "2023-10-25T23:32:02Z")

</div>

I see that toposolids have a SketchId property. Can you use that to pull the sketch, and use that to pull the profile, take the largest curve loop from that, and convert each of the curves contained therein?

---

<div class="post-metadata">

**Author:** ![Pedehh](https://avatars.discourse-cdn.com/v4/letter/p/e0b2c6/32.png) [@Pedehh](https://forum.dynamobim.com/u/Pedehh)\
**Post date:** [October 26, 2023, 6:19am UTC](https://forum.dynamobim.com/t/collecting-the-perimeter-curves-of-a-toposolid/94913/3 "2023-10-26T06:19:06Z")

</div>

Sounds like an interresting approach to my problem.  
I tried for a bit, cant seem to extract the sketch? Any nodes for this?

Cant upload script, since im a new user ☹

---

<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:** [October 26, 2023, 6:32am UTC](https://forum.dynamobim.com/t/collecting-the-perimeter-curves-of-a-toposolid/94913/4 "2023-10-26T06:32:29Z")

</div>

Bumped your trust level. If you still can’t post try a 3rd party service (onedrive, Dropbox, Google drive, etc.). Best to include a rvt with a small Toposolid as well.

---

<div class="post-metadata">

**Author:** ![Pedehh](https://avatars.discourse-cdn.com/v4/letter/p/e0b2c6/32.png) [@Pedehh](https://forum.dynamobim.com/u/Pedehh)\
**Post date:** [October 26, 2023, 12:37pm UTC](https://forum.dynamobim.com/t/collecting-the-perimeter-curves-of-a-toposolid/94913/5 "2023-10-26T12:37:07Z")

</div>

Heres a link, with the .DYN a revit file, with a simple toposolid.

> **[Toposolid](https://www.dropbox.com/scl/fo/n35yjvwat1l18jddbpuj1/h?rlkey=9zlwo9u8543ytzzt2hzn020tp&dl=0)**
>
> Shared with Dropbox

The old approach, was to convert the topography’ surface to a mesh, and extract points from that. you can see that i the .DYN could something similiar be done to the toposolid? Or are there smarter ways, im kind of run out of ideas 🙂 And i dont know how to sort away, the faces that arent on the toposolids top. Thx so much for looking in to this. Just asking for pointers, so i can get there

---

<div class="post-metadata">

**Author:** ![solamour](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/solamour/32/153516_2.png) [@solamour](https://forum.dynamobim.com/u/solamour)\
**Post date:** [October 26, 2023, 1:52pm UTC](https://forum.dynamobim.com/t/collecting-the-perimeter-curves-of-a-toposolid/94913/6 "2023-10-26T13:52:16Z")

</div>

Hi @Pedehh - here is one way you could do it 🙂

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/8/78193b997357a9deca3ba92423afc811814a231e.png)

[Pedehh\_GetToposolidPerimeterCurves.dyn](https://forum.dynamobim.com/uploads/short-url/rwUx2iKCHValyj8nILdlocLiJJw.dyn) (8.5 KB)

```auto
# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('RevitAPI')
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

# Import Revit elements and geometry classes
from Autodesk.Revit.DB import *

# Get the current Revit document
doc = DocumentManager.Instance.CurrentDBDocument

# Input: Toposolid Element
topo = UnwrapElement(IN[0])

# Ensure that we have a list of elements, not a singleton
if not isinstance(topo, list):
    topo = [topo]

# Raise a value error if nothing is selected
if topo is None:
    raise ValueError("Please provide a valid Toposolid element.")

# Initialize an empty list to store the curves
curves = []

# Start a transaction
TransactionManager.Instance.EnsureInTransaction(doc)

for t in topo:
    # Get the SketchID property from the floor
    sketch_id = t.SketchId
    

    # Get the sketch associated with the SketchID
    sketch = doc.GetElement(sketch_id)
    
    # Check if the sketch is valid
    if sketch:
        # Get the curves from the sketch
        for curve in sketch.Profile:
            curves.append(curve)
    else:
        curves = "No sketch found for the given Toposolid."

# End the transaction
TransactionManager.Instance.TransactionTaskDone()

# Output: List of curves
OUT = [c.ToProtoType() for c in curves]
```

---

<div class="post-metadata">

**Author:** ![Pedehh](https://avatars.discourse-cdn.com/v4/letter/p/e0b2c6/32.png) [@Pedehh](https://forum.dynamobim.com/u/Pedehh)\
**Post date:** [October 26, 2023, 2:49pm UTC](https://forum.dynamobim.com/t/collecting-the-perimeter-curves-of-a-toposolid/94913/7 "2023-10-26T14:49:49Z")

</div>

Hi there

That seems really tight… I get a warning when using it? Just launched it, and gave it a go on the same rvt. file. Are you picture tricking me, or at the line not following all the way around the toposolid?

 ![Emne](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/1/e14a70223add012272b3072cfbea7a498efb9c8e.jpeg)

---

<div class="post-metadata">

**Author:** ![solamour](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/solamour/32/153516_2.png) [@solamour](https://forum.dynamobim.com/u/solamour)\
**Post date:** [October 26, 2023, 3:28pm UTC](https://forum.dynamobim.com/t/collecting-the-perimeter-curves-of-a-toposolid/94913/8 "2023-10-26T15:28:26Z")

</div>

I would need to test with your actual toposolid… not my own 😛 I can give it a go and resolve.

---

<div class="post-metadata">

**Author:** ![solamour](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/solamour/32/153516_2.png) [@solamour](https://forum.dynamobim.com/u/solamour)\
**Post date:** [October 26, 2023, 3:36pm UTC](https://forum.dynamobim.com/t/collecting-the-perimeter-curves-of-a-toposolid/94913/9 "2023-10-26T15:36:38Z")

</div>

@Pedehh I downloaded your Toposolid and it’s working for me. Just confirming this is your toposolid?

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/9/1/91686fabf8b7100ea2dbb016a64fb3c9cc9a1662.jpeg)

---

<div class="post-metadata">

**Author:** ![christian.stan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/christian.stan/32/166296_2.png) [@christian.stan](https://forum.dynamobim.com/u/christian.stan)\
**Post date:** [October 26, 2023, 3:43pm UTC](https://forum.dynamobim.com/t/collecting-the-perimeter-curves-of-a-toposolid/94913/10 "2023-10-26T15:43:48Z")

</div>

Hello Mr. Solamour, do we no longer need to import these lines

```auto
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

```

into Dynamo for Revit 2024?

Sincerely  
Christian.stan

---

<div class="post-metadata">

**Author:** ![solamour](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/solamour/32/153516_2.png) [@solamour](https://forum.dynamobim.com/u/solamour)\
**Post date:** [October 26, 2023, 3:51pm UTC](https://forum.dynamobim.com/t/collecting-the-perimeter-curves-of-a-toposolid/94913/11 "2023-10-26T15:51:39Z")

</div>

Ah… there it is! So, funnily enough it was working for me **without** those imported extensions as I had **already loaded them into my sessions**. You 💯 have to have them, so I’ll edit my code above.

Great catch @christian.stan!

---

<div class="post-metadata">

**Author:** ![solamour](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/solamour/32/153516_2.png) [@solamour](https://forum.dynamobim.com/u/solamour)\
**Post date:** [October 26, 2023, 3:53pm UTC](https://forum.dynamobim.com/t/collecting-the-perimeter-curves-of-a-toposolid/94913/12 "2023-10-26T15:53:00Z")

</div>

@Pedehh please re-copy through the code from my original post as i’ve now edited it and it should work thanks to @christian.stan 's call out 🙂

---

<div class="post-metadata">

**Author:** ![christian.stan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/christian.stan/32/166296_2.png) [@christian.stan](https://forum.dynamobim.com/u/christian.stan)\
**Post date:** [October 26, 2023, 4:00pm UTC](https://forum.dynamobim.com/t/collecting-the-perimeter-curves-of-a-toposolid/94913/13 "2023-10-26T16:00:11Z")

</div>

By pestering me with lots of questions, I’m starting to understand certain parts of the scripts (which seemed very, very obscure to me at first) but I still have a lot of work to do to understand 😉

Sincerely  
christian.stan

---

<div class="post-metadata">

**Author:** ![Pedehh](https://avatars.discourse-cdn.com/v4/letter/p/e0b2c6/32.png) [@Pedehh](https://forum.dynamobim.com/u/Pedehh)\
**Post date:** [October 27, 2023, 6:20am UTC](https://forum.dynamobim.com/t/collecting-the-perimeter-curves-of-a-toposolid/94913/14 "2023-10-27T06:20:49Z")

</div>

@christian.stan - Loving all the pros around here. Thanks so much for the help.

@solamour - It worked, thx so much for the time. I think i might af formulated my problem a bit weak, bechause i have now the perimeter, as i asked for 🙂 But acutally what i need is the top edge of the toposolid…  
Can i someway, pull the sketch to the plane of the edge? Maybe moving endpoints in Z-value, if i can some way collect that?

 ![Points](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/0/7051c73fa844cad2ce63ff1bfcd8697bc0d80f89.png)

---

<div class="post-metadata">

**Author:** ![christian.stan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/christian.stan/32/166296_2.png) [@christian.stan](https://forum.dynamobim.com/u/christian.stan)\
**Post date:** [October 27, 2023, 12:14pm UTC](https://forum.dynamobim.com/t/collecting-the-perimeter-curves-of-a-toposolid/94913/15 "2023-10-27T12:14:57Z")

</div>

Hello, here is a search process based on your points (it may be faster, most certainly, I do not have Revit2024 to test on your example)

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/6/a6757de395847913c658c2349e014ae6bf1239f8.jpeg)

Cordially  
christian.stan

---

<div class="post-metadata">

**Author:** ![Vikram\_Subbaiah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/vikram_subbaiah/32/50797_2.png) [@Vikram\_Subbaiah](https://forum.dynamobim.com/u/Vikram_Subbaiah)\
**Post date:** [October 27, 2023, 3:46pm UTC](https://forum.dynamobim.com/t/collecting-the-perimeter-curves-of-a-toposolid/94913/16 "2023-10-27T15:46:14Z")

</div>

> [@Pedehh](#):
>
> But acutally what i need is the top edge of the toposolid

 ![toposolid_2023-10-27_09-14-16](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/6/f6b03893ed61864ca74561d3d1db33a68f6fd54e.png)  
[toposolid.dyn](https://forum.dynamobim.com/uploads/short-url/wJQ8BPK1APAuq1gXEJQoygNxRUd.dyn) (26.8 KB)

---

<div class="post-metadata">

**Author:** ![Pedehh](https://avatars.discourse-cdn.com/v4/letter/p/e0b2c6/32.png) [@Pedehh](https://forum.dynamobim.com/u/Pedehh)\
**Post date:** [October 27, 2023, 6:53pm UTC](https://forum.dynamobim.com/t/collecting-the-perimeter-curves-of-a-toposolid/94913/17 "2023-10-27T18:53:55Z")

</div>

Thx so much for the effort! Problem is that i cant use topography nodes, since it aint a topography, but a toposolid 🙂 Vikram send a real tight code… 🙂

---

<div class="post-metadata">

**Author:** ![Pedehh](https://avatars.discourse-cdn.com/v4/letter/p/e0b2c6/32.png) [@Pedehh](https://forum.dynamobim.com/u/Pedehh)\
**Post date:** [October 27, 2023, 6:54pm UTC](https://forum.dynamobim.com/t/collecting-the-perimeter-curves-of-a-toposolid/94913/18 "2023-10-27T18:54:29Z")

</div>

That is just amazing. Well written, thanks so much

---

<div class="post-metadata">

**Author:** ![christian.stan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/christian.stan/32/166296_2.png) [@christian.stan](https://forum.dynamobim.com/u/christian.stan)\
**Post date:** [October 27, 2023, 6:59pm UTC](https://forum.dynamobim.com/t/collecting-the-perimeter-curves-of-a-toposolid/94913/19 "2023-10-27T18:59:15Z")

</div>

ah sorry it’s a change under Revit 2024 (Toposolid I think), it can still be useful, you have good answer from Mr. Vikram (pro: more adequate qualitative)

cordially  
christian.stan

---

<div class="post-metadata">

**Author:** ![solamour](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/solamour/32/153516_2.png) [@solamour](https://forum.dynamobim.com/u/solamour)\
**Post date:** [October 28, 2023, 12:11am UTC](https://forum.dynamobim.com/t/collecting-the-perimeter-curves-of-a-toposolid/94913/20 "2023-10-28T00:11:38Z")

</div>

Here’s another option to go along side @Vikram_Subbaiah 's great solution 🙂 Similar, but a little different!

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/1/5196c8ac499c325a9761cb2d850fc2790ec2b22d.png)

[Pedehh\_GetToposolidTopFacePerimeterCurves.dyn](https://forum.dynamobim.com/uploads/short-url/aB6lmvHJdW2NUZZGSmyntN1hhWE.dyn) (18.1 KB)

[Next page](https://forum.dynamobim.com/t/collecting-the-perimeter-curves-of-a-toposolid/94913.md?page=2)
