Collecting the perimeter curves of a Toposolid

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?

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?

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 :frowning:

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.

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

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 :slight_smile: 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

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

Pedehh_GetToposolidPerimeterCurves.dyn (8.5 KB)

# 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]
5 Likes

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?

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

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

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

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

into Dynamo for Revit 2024?

Sincerely
Christian.stan

1 Like

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 :100: have to have them, so I’ll edit my code above.

Great catch @christian.stan!

2 Likes

@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 :slight_smile:

1 Like

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 :wink:

Sincerely
christian.stan

2 Likes

@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 :slight_smile: 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?

2 Likes

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)

Cordially
christian.stan


toposolid.dyn (26.8 KB)

6 Likes

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

1 Like

That is just amazing. Well written, thanks so much

1 Like

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

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

Pedehh_GetToposolidTopFacePerimeterCurves.dyn (18.1 KB)

3 Likes