I have created floor by outlines but wanted to give some slope (1:50 or 0.02 both are same). But when I try to give slope by setting element parameters such as slope, it is giving me an error like slope is read only parameters.
Dont think its possible,you could try make slope with your floor sketchline but not sure it will gonna work… but you can add floor points and move floorpoints
@shashank.baganeACM the line variable is getting the slope direction from the curve array, check which curve is parallel to the desired direction you want your slope and specify the right index: line = ca[1 or 2 or 3 or…]
Either I want slope along the slope arrow direction then how to do that ? I am trying but added one input to take the reference of marked sloped arrow line and I am not getting how to assign slope along the line which we want.
hello @shashank.baganeACM …i dont want edit the code…i would try with some intersecting and start the curve array from there…im not in revit at the moment i take a look later happy new year
Rather than picking an edge via list manipulation, it might be better to ask the user to specify a vector, as otherwise the floor could slope backwards (up instead of down), though along the right path.
This does require manipulating the code to some extent, but it’s not to the point where you can’t recognize the initial concept.
import clr #imports the common language runtime to the Iron Python environment
clr.AddReference('RevitAPI') #adds the Revit API library to the CLR
from Autodesk.Revit.DB import Floor, CurveArray #imports the Floor and Curve array modules to the Iron Python environment
clr.AddReference('RevitNodes') #adds the DynamoForRevit library to the CLR
import Revit #imports the Dynamo for Revit module to the Iron Python environment
clr.ImportExtensions(Revit.GeometryConversion) #imports the geometry conversion module to the Iron Python environment
clr.AddReference('RevitServices') #adds the Revit services module to the CLR
import RevitServices #imports the Revit services module to the Iron Python environment
from RevitServices.Persistence import DocumentManager #imports the Revit DocumentManager to the Iron Python Environment
from RevitServices.Transactions import TransactionManager #imports the Revit TransactionManager to the Iron Python environment
clr.AddReference('ProtoGeometry') #addds the geometry library to the CLR
from Autodesk.DesignScript.Geometry import * #imports the dynamo geometry library to the Iron Python environment
doc = DocumentManager.Instance.CurrentDBDocument #sets the doc variable to the current document
outlineLoop = IN[0] #sets the outlineLoop variable to the contents of IN[0] from the Dynamo environment
level = UnwrapElement(IN[1]) #unwraps the contents of IN[1] from the Dynamo environment so it can be used in the Revit API directly and sets the result to the level variable
slopeVector = IN[2] #converts the contents of IN[2] to the associated Revit content and sets the result to the slopeLine variable
slope = IN[3] #sets the slope variable to the contents of IN[2] from the Dynamo environment
floorType = UnwrapElement(IN[4]) #unwraps the contents of IN[4] from the Dynamo environment so it can be used int he Revit API directly, and sets the result to the floorType variable
x = [] #creates an empty list as the x variable
y = [] #creates an empty list as the y variable
z = [] #creates an empty list as the z variable
TransactionManager.Instance.EnsureInTransaction(doc) #starts a new transaction so we can modify the document in the doc variable
ca = CurveArray() #sets a new curve array as an empty CurveArray
for c in outlineLoop: #for each curve int he outlineLoop, perform the offset action below
ca.Append(c.ToRevitType()) #converts the curve to the associated Revit type, and appends it to the curve ca variable
sp = c.StartPoint #gets the start point of each curve
x.append(sp.X) #appends the start point's X value to the x variable
y.append(sp.Y) #appends the start point's Y value to the y vairable
z.append(sp.Z) #appends the start point's Z value to the z vairable
x = sum(x)/len(x) #sets the x variable to the average of the start point values
y = sum(y)/len(y) #sets the y variable to the average of the start point values
z = sum(z)/len(z) #sets the z variable to the average of the start point values
slopeLine = Line.ByStartPointDirectionLength(Point.ByCoordinates(x,y,z),slopeVector,10).ToRevitType() #builds a new line 10 unit long line from the average start point on the given vector and converts to a Revit line to use in the floor creation
floor = doc.Create.NewSlab(ca, level, slopeLine, slope, True) #creates a new floor in the document stored in the doc variable, using the ca, level, slopeLine, and slope variable, and setting the 'is structural' override to true, setting the result to the floor variable
floor.FloorType = floorType #sets the floor type to the contents of the floorType variable
TransactionManager.Instance.TransactionTaskDone() #closes the Revit transaction
OUT = floor #sends the contents of the floor variable to the Dynamo environment