Get Curves From SlabShapeCrease

Hi all,
I have a slab that has split lines and I am trying to get the crease line in order to give it an offset.
Before hand I would like to get the curve of the crease lines which I seem to get an error with.

I try getting the curve using SlabShapeCrease.Curve but I am getting an error that “Autodesk.Revit.Db.SlabShapeCrease has no attribute get_Curve”.
I am using Revit 2023.

Any idea why this is? Appreciate the help :pray:

Here is the code I am using:

import clr
import sys

clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

import RevitServices
from RevitServices.Persistence import DocumentManager 
from RevitServices.Transactions import TransactionManager 

clr.AddReference('RevitAPI')


import Autodesk 
from Autodesk.Revit.DB import *


doc = DocumentManager.Instance.CurrentDBDocument


floors = UnwrapElement(IN[0]) if isinstance(UnwrapElement(IN[0]),list) else [UnwrapElement(IN[0])]


floor = floors[0]


slabEdit = floor.SlabShapeEditor

creases = slabEdit.SlabShapeCreases
curve = []

for crease in creases:
    curve.append(crease.Curve.ToProtoType())

OUT =  curve

Still haven’t managed to figure this out. Anybody know about this?

I just managed to get the curve elements but am having an issue now with converting to dynamo curve. I tried using ToProtoType() and ToDynamoType(), I tried also CurveElement.Curve but seems like it isn’t working…

Any ideas?

This is the code:

import clr
import sys

import System
from System import Array
from System.Collections.Generic import *
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager 
from RevitServices.Transactions import TransactionManager 

clr.AddReference('RevitAPI')
clr.AddReference('RevitAPIUI')

import Autodesk 
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import *

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication 
app = uiapp.Application 
uidoc = uiapp.ActiveUIDocument

floors = UnwrapElement(IN[0]) if isinstance(UnwrapElement(IN[0]),list) else [UnwrapElement(IN[0])]


floor = floors[0]
slabShapeE = floor.SlabShapeEditor

sLines = slabShapeE.SlabShapeCreases
iter = sLines.ForwardIterator()

li = []

for it in sLines:
   
        if it.CreaseType==2:
            c = it.Curve
            li.append(c)  # For other types of curves, use the default 

OUT = li

This is the slab and creases.

Can you post a slab copy here?

Sure.
Revit Files.rvt (6.8 MB)

Hi

try to clone the curves

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 net library
from System import Array
from System.Collections.Generic import List, IList, Dictionary

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.GeometryReferences)

#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

floors = UnwrapElement(IN[0]) if isinstance(UnwrapElement(IN[0]),list) else [UnwrapElement(IN[0])]

floor = floors[0]

slabEdit = floor.SlabShapeEditor

creases = slabEdit.SlabShapeCreases
lst_curves = []
for crease in creases:
    try:
        curve = crease.Curve.Clone()
        lst_curves.append([curve.ToProtoType(), System.Enum.GetName(SlabShapeCreaseType, crease.CreaseType )])
    except Exception as ex:
        print(ex)

OUT =  lst_curves
1 Like

exactly

1 Like

conversion failed on my machine too. But you can clone them.

for it in sLines: 
    if it.CreaseType==2:
        c = it.Curve
        # Revit.GeometryConversion.RevitToProtoCurve.Convert(c)
        li.append([c.GetEndPoint(0).ToPoint(), c.GetEndPoint(1).ToPoint()])  # For other types of curves, use the default 

Though I am not sure why ToProtoType failed.

2 Likes

Thank you!
Care to explain why is necessary to clone the curve for it to work?

If I may ask another question related, I want to modify the line heights using subelements. When I selected the crease type 2 it seemed to have returned all the creases that are mid slab not including the first and last (based on the count of creases in the list). What would be the best method to get the creases in order including the first and last for further modifying? Or is it better to just create a new slab with the modified geometry?

ToProtoType() method explicitly needs the curve type (DB.Line, DB.Arc, etc…) and SlabShapeCrease.Curve Property only returns an object of Type DB.Curve (maybe a bug)

so I tried using Clone() to re-create a copy of the geometry in the specific Type

For the order of the lines, I’ll use one of the 2 arcs as a guide (calculating the parameter on the arc for each line).