I am trying to create a floor using Python.
I want the floor in a different location.
Can someone help me with how to move the Lines?
I found this:
when I try this I get error
*Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed. *
Traceback (most recent call last):
File “”, line 51, in
AttributeError: ‘Line’ object has no attribute ‘CreateTranslation’
import clr
# import RevitNodes
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
# import Revit Services
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
# import system.
import System
from System.Collections.Generic import *
# get the current Revit document.
doc = DocumentManager.Instance.CurrentDBDocument
floors = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Floors).WhereElementIsElementType().ToElements()
levels = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Levels).WhereElementIsNotElementType().ToElements()
def createCurve():
l = 200
h = 200
p_1 = XYZ(0, 0, 0)
p_2 = XYZ(0, h, 0)
p_3 = XYZ(l, h, 0)
p_4 = XYZ(l, 0, 0)
line_1 = Line.CreateBound(p_1, p_2)
line_2 = Line.CreateBound(p_2, p_3)
line_3 = Line.CreateBound(p_3, p_4)
line_4 = Line.CreateBound(p_4, p_1)
curveArray = CurveArray()
curveArray.Append(line_1)
curveArray.Append(line_2)
curveArray.Append(line_3)
curveArray.Append(line_4)
return curveArray
myVector = XYZ(40,50,0);
crvs=createCurve()
for crv in crvs:
crv.CreateTranslation(myVector);
TransactionManager.Instance.EnsureInTransaction(doc)
floorNew = doc.Create.NewFloor(crvs, floors[0], levels[0], Structure.StructuralType.Footing)
TransactionManager.Instance.TransactionTaskDone()
OUT = floorNew