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?
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 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
# 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]
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?
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.
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
@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?
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)