Floor Boundry curves

Hi, I’m attempting to obtain the floor boundary, but it’s inconsistent, especially when dealing with a modified sub-element. Does anyone have insights on reliably acquiring the boundary curve?

@J.Sharma ,

i don`t exactly what you want to do, i had a similar topic, getting perimeter curves. The script covers also slanted floors. Look at my code:

# -*- coding: utf-8 -*-
__title__ = ("Floor"
             "Perimeter")
__doc__ = """Version = 1.0
Date    = 29.10.2023Version = 1.0

Date    = 29.10.2023
_____________________________________________________________________
Description:
This is a template file for pyRevit Scripts.
_____________________________________________________________________
How-to:
-> Click on the button
-> Get floor perimeter is there and correct!
_____________________________________________________________________
Last update:
- [24.04.2022] - 1.0 RELEASE
_____________________________________________________________________
To-Do:
- 
_____________________________________________________________________
Author: Andreas Draxl"""



# ╦╔╦╗╔═╗╔═╗╦═╗╔╦╗╔═╗
# ║║║║╠═╝║ ║╠╦╝ ║ ╚═╗
# ╩╩ ╩╩  ╚═╝╩╚═ ╩ ╚═╝ IMPORTS
# ==================================================
# Regular + Autodesk
import Autodesk
from Autodesk.Revit.DB import *
import System

import traceback
import time
#import ipywidgets as widgets
#from IPython.display import display
from pyrevit import script, revit, DB, forms
from collections import Counter

# pyRevit
from pyrevit import revit, forms
from pyrevit import DB, UI
from pyrevit import PyRevitException, PyRevitIOError

# pyrevit module has global instance of the
# _HostAppPostableCommand and _ExecutorParams classes already created
# import and use them like below

from pyrevit import HOST_APP
from pyrevit import EXEC_PARAMS
from pyrevit.compat import safe_strtype
from pyrevit import framework
from pyrevit.output import linkmaker
from pyrevit.userconfig import user_config

# .NET Imports
import clr

clr.AddReference("System")

from System.Collections.Generic import List
from collections import defaultdict
# ╦  ╦╔═╗╦═╗╦╔═╗╔╗ ╦  ╔═╗╔═╗
# ╚╗╔╝╠═╣╠╦╝║╠═╣╠╩╗║  ║╣ ╚═╗
#  ╚╝ ╩ ╩╩╚═╩╩ ╩╚═╝╩═╝╚═╝╚═╝ VARIABLES
# ==================================================

doc = __revit__.ActiveUIDocument.Document
uidoc = __revit__.ActiveUIDocument
app = __revit__.Application


time_start = time.time()


# 📝 Variables LOI
PERIMETER = "Umfang_Massen"


# 🎹 functions
def tolist(x):
    if hasattr(x, '__iter__'):
        return x
    else:
        return [x]

def isSolid(x):
    if x.__class__ == Autodesk.Revit.DB.Solid: return x

def faceNormal(face):
    if face.FaceNormal.Z > 0.00001: return [edges.append(i) for loop in face.EdgeLoops for i in loop]


# 1️⃣ Get floors
collector = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Floors).WhereElementIsNotElementType().ToElements()

roofs = tolist(collector)

# 2️⃣ extract lengths from edges of floors
results = []

for e in roofs:
    edges = []
    processed = []
    geos = e.get_Geometry(Options())
    for geo in geos:
        faces = isSolid(geo)
        faces = geo.Faces
        for face in faces:
            loop = faceNormal(face)

    pnts = [e.AsCurve().Evaluate(0.5, True) for e in edges]
    # get all the mid points of the edges

    for i in range(len(edges)):  # for every item in the list of edges
        e = edges.pop(0)  # remove the edge to process
        p = e.AsCurve().Evaluate(0.5, True)  # get the midpoint
        distSum = sum([1 for i in pnts if i.DistanceTo(p) == 0])
        # get the count of midpoints which are equal to the midpoint being evaluated
        if distSum == 1: processed.append(e.AsCurve().Length)
        # ToProtoType()) #if the count was 0 the edge isn't shared and is on the perimeter
    results.append(processed)  # append the processed edges to our results list

print(results)
"""
# 3️⃣ sum edge.lengths to perimeter total per floor
total = []

for lis in results:
    perimeter_per_element = sum(lis)
    total.append(perimeter_per_element)

# 🔓 SetParameter
t = Transaction(doc, "Set Massen_Umfang")
t.Start()

for d, v in zip(roofs, total):
    try:
        roof_perimeter_param = d.LookupParameter(PERIMETER).Set(v)
    except:
        pass

t.Commit()
# 🔒 parameter filled
"""

time_end = time.time()
duration = time_end - time_start
print('\n The code took {} seconds to run.'.format(duration))
# ✅ End

I can see the numbers but not the curves; what I am trying to do is create a filled region from those curves.

@J.Sharma

ok check out this video. i think you can brigding the gab…

I am able to create filled regions for floors, but for floors with slab shapes that have been edited, I can’t achieve those curves.

1 Like

puh, @J.Sharma seems to be you need the real geometry, do you have a screenshot.

image

1 Like

I think i get now why i am not getting the curves for slabshapes

FLOOR 2 FR_1

This is what i wanted.

@J.Sharma

we model each triangle separatly, to control the edges… OK, i understand what you want to access.

1 Like