pdrew
March 29, 2019, 8:51pm
1
I’m attempting to create a sloped floor in Revit using Dynamo.
It’s easy to create a flat floor using Rectangle.By.WidthLength and Floor.ByOutlineTypeAndLevel. Once this rectangle is at an angle Dynamo throws errors and refuses to draw the same thing at an angle. Seems like there should be no difference. I’ve tried projecting onto a plane and pulling to a surface (pictured below).
Any help?
(First post, no idea the best way to show a reproduce-able code block)
Flat Floor
Attempt at angled floor
Error: Input normal vector is not perpendicular with the face constructed from input curves
Floors have to be level on creation, and then have the shapes edited.
Kulkul
March 31, 2019, 6:03pm
3
Hi @pdrew
Floors are sketch-based, and the sketch must be planar, perpendicular to the Z-Axis (on a level). So, to create it from Dynamo, you’ll have to build the curves onto a planeXY. However you can create sloped after placing them on a plane like this:
Cheers!
6 Likes
@Kulkul great answer.
There is also another way, using Slope Arrow instead of editing the points in the slab. It uses this API method: https://apidocs.co/apps/revit/2017/983a7045-e2c0-db60-61b7-9e37749f1c6a.htm
Here’s an example:
It was created with this Dynamo script:
The code for the Python node is the following:
# Copyright(c) 2019, Konrad K Sobon
# @arch_laboratory, http://archi-lab.net
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# Import Element wrapper extension methods
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
# Import geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
import System
from System import Array
from System.Collections.Generic import *
import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)
#The inputs to this node will be stored as a list in the IN variable.
dataEnteringNode = IN
def ProcessList(_func, _list):
return map( lambda x: ProcessList(_func, x) if type(x)==list else _func(x), _list )
def ProfileToCrvArray(profile):
crvArr = CurveArray()
for crv in profile.Curves():
startPt = crv.PointAtParameter(0).ToXyz()
endPt = crv.PointAtParameter(1).ToXyz()
rvtLine = Line.CreateBound(startPt, endPt)
crvArr.Append(rvtLine)
return crvArr
def LineToRvtLine(crv):
startPt = crv.PointAtParameter(0).ToXyz()
endPt = crv.PointAtParameter(1).ToXyz()
rvtLine = Line.CreateBound(startPt, endPt)
return rvtLine
def CreateRamp(profile, level, slopedArrow, slope, isStr):
crvArray = ProfileToCrvArray(profile)
slopeLine = LineToRvtLine(slopedArrow)
newFloor = doc.Create.NewSlab(crvArray, level, slopeLine, slope, isStr)
return newFloor
profiles = IN[0]
level = UnwrapElement(IN[1])
slopeLines = IN[2]
slopes = IN[3]
isStructural = IN[4]
floorType = UnwrapElement(IN[5])
RunIt = IN[6]
if RunIt:
try:
errorReport = None
TransactionManager.Instance.EnsureInTransaction(doc)
output = []
for i, j, k in zip(profiles, slopeLines, slopes):
newFloor = CreateRamp(i, level, j, k, isStructural)
if newFloor != None:
newFloor.FloorType = floorType
output.append(newFloor)
TransactionManager.Instance.TransactionTaskDone()
except:
import traceback
errorReport = traceback.format_exc()
else:
errorReport = "Please set RunIt to True."
if errorReport == None:
OUT = output
else:
OUT = errorReport
9 Likes
Yousra
April 11, 2019, 4:11pm
5
I’ve tried your dynamo script for creating a sloped floor but for some reason It doesn’t work for me.
Kulkul
April 11, 2019, 4:58pm
6
Hi @Yousra
Could you please start new topic showing full graph with all previews visible. This topic has already solution.