Slabs, point driven or slanted, how to get the difference?


# 0️⃣ Get slanted slab
slabs = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Floors).WhereElementIsNotElementType().ToElements()

# Thickness from slab parameter
thickness_slab = [
    round(UnitUtils.Convert(
        i.get_Parameter(BuiltInParameter.FLOOR_ATTR_THICKNESS_PARAM).AsDouble(),
        UnitTypeId.Feet,
        UnitTypeId.Centimeters
    )) for i in slabs
]

# 1️⃣ Thickness from bounding box
thickness_Box = []

# 2️⃣ Bounding Box
get_slanted_slabs = []

for idx, e in enumerate(slabs):
    bb = e.get_BoundingBox(None)
    if bb:  # Ensure the bounding box is not None
        delta = bb.Max.Z - bb.Min.Z
        unitMetric = round(UnitUtils.Convert(delta, UnitTypeId.Feet, UnitTypeId.Centimeters))
        thickness_Box.append(unitMetric)

        # Compare bounding box thickness with parameter thickness
        if abs(thickness_slab[idx] - unitMetric) > 0.1:  # Use a small tolerance
            get_slanted_slabs.append(e)

# ✅ Output results
OUT = [s.Name for s in get_slanted_slabs]

My code works pretty well do get all slanted floors, but how can i check if they are point driven or slanted modeled ?



Try getting the slab shape editor and see if it is enabled.

Also, check if a situation where both slave shape edits and the slope arrow exists. If so you’ll also have to get the sketch and see if it has any lines defining slope.

2 Likes

@jacob.small

background is that the model style has impact on the geometry. Revit generates the volume with math, BUT rip iTwo extracts it from the “true” geometry"



SlabShapeEditor Class

A solution by analyzing the type of faces (PlanarFace or other)

import clr
import sys
import System
#
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import Autodesk.DesignScript.Geometry as DS

#import Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB

#import transactionManager and DocumentManager (RevitServices is specific to Dynamo)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
    
def is_driven(elem):
    global opt
    faces = []
    elem_geos = elem.get_Geometry(opt)
    if elem_geos is not None:
        for geo in elem_geos:
            if isinstance(geo, DB.Solid):
                for face in geo.Faces:
                    faces.append(face)
    elem_geos.Dispose()
    return not all(isinstance(f, DB.PlanarFace) for f in faces) if faces else False
    

def toList(x):
    if isinstance(x, (list, dict)) or \
            (hasattr(x, "GetType") and x.GetType().GetInterface("ICollection") is not None):
        return x
    else : return [x]

opt = Options()
lstelems = toList(UnwrapElement(IN[0]))


OUT = [is_driven(e) for e in lstelems]
1 Like

@c.poupin

meanwhile i made this in pyRevit. It is more user friendly…

# -*- coding: utf-8 -*-
__title__ = "Slanted"
__doc__ = """Date    = 29.12.2022
_____________________________________________________________________
Description:
Toggle visibility of room categories (Color Fill and Interior Fill) in the active view.
_____________________________________________________________________
Author: """

# IMPORTS
#==================================================
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Architecture import Room

#pyrevit
from pyrevit import forms, script

# .NET Imports
import clr
clr.AddReference("System")

# VARIABLES
#==================================================
uidoc = __revit__.ActiveUIDocument
doc   = uidoc.Document
view  = doc.ActiveView

# 🎯 get Linkify Function
output = script.get_output()
linkify = output.linkify

# 0️⃣ Get slanted slab
slabs = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Floors).WhereElementIsNotElementType().ToElements()
slab_name = [i.Name for i in slabs]

# Thickness from slab parameter
thickness_slab = [
    round(UnitUtils.Convert(
        i.get_Parameter(BuiltInParameter.FLOOR_ATTR_THICKNESS_PARAM).AsDouble(),
        UnitTypeId.Feet,
        UnitTypeId.Centimeters
    )) for i in slabs
]

#  Thickness from bounding box
thickness_Box = []

# 🔀 order model style of slabs
get_default_slabs = []
get_slanted_slabs = []

#  Bounding Box
for idx, e in enumerate(slabs):
    bb = e.get_BoundingBox(None)
    if bb:  # Ensure the bounding box is not None
        delta = bb.Max.Z - bb.Min.Z
        unitMetric = round(UnitUtils.Convert(delta, UnitTypeId.Feet, UnitTypeId.Centimeters))
        thickness_Box.append(unitMetric)

        # Compare bounding box thickness with parameter thickness
        if abs(thickness_slab[idx] - unitMetric) > 0.1:  # Use a small tolerance (chatGPT)
            get_slanted_slabs.append(e)
        else:
            get_default_slabs.append(e)

slanted_type = []

#  get point driven slabs
for slanted in get_slanted_slabs:
    ss_editor = slanted.SlabShapeEditor

    if hasattr(ss_editor, "IsEnabled"):
        slanted_type.append("point driven")
    else:
        slanted_type.append("direction driven")

slab_id = []

# get slanted elements actively
for s in slabs:
    linkify_slanted_slabs = linkify(s.Id, "{}".format(str(s.Id)))
    slab_id.append(linkify_slanted_slabs)

# Transpose the table data to list each element vertically
table_data = list(zip(slab_id, slab_name, slanted_type + ["N/A"] * (len(slab_id) - len(slanted_type)), thickness_slab))

#  Output results in a table
output.print_table(
    table_data=table_data,
    title="Slabs Check",
    columns=["Id", "Type", "Shape Type", "Thickness (cm)"],
    formats=['', '', '', '{}'],
)

1 Like