In this part of the code, I defined a function, Create_footings, which creates footings at the lowest level retrieved by the function get_foundation_level(). The code runs without any issues; however, the footings are misplaced and offset by a distance equal to 2 × level.Elevation, as shown in the image below.
Note: I checked that the choosed level’s Elevation is correctly converted to Revit internal units and matches the lowest level. I used this method to create footings:
...python
...
def get_foundation_level():
"""Return the foundation level in the document with the minimum elevation."""
levels = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Levels) \
.WhereElementIsNotElementType().ToElements()
return min(levels, key=lambda l: l.Elevation)
...
...
def Create_footings(points, family_symbol, level, material_id, doc):
with Transaction(doc, "Create Footings") as t:
t.Start()
for p in points:
z= level.Elevation
# Create the footing at the proper elevation
foot = doc.Create.NewFamilyInstance(XYZ(p.X, p.Y, z), family_symbol, level, StructuralType.Footing)
# Assign material
material_param = foot.get_Parameter(BuiltInParameter.STRUCTURAL_MATERIAL_PARAM)
if material_param:
material_param.Set(material_id)
t.Commit()
The level is already at an altitude of -6m. doc.Create.NewFamilyInstance(XYZ(p.X, p.Y, 0), family_symbol, level, StructuralType.Footing)
Sincerely,
Christian.stan
Does this mean that only the (X, Y) coordinates are taken into account to determine the footing location in a 2D plan, while the third coordinate (Z) is retrieved from the level’s elevation?
import sys
import clr
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import Transaction,Level,XYZ
from Autodesk.Revit.DB.Structure import StructuralType
elts=UnwrapElement(IN[0])
fs=UnwrapElement(IN[2])
lvl=UnwrapElement(IN[1])
doc=elts[0].Document
ptsloc=[e.Location.Point for e in elts]
npts=[XYZ(ptsloc[0].X,ptsloc[0].Y,0),XYZ(ptsloc[1].X,ptsloc[1].Y,lvl.Elevation),XYZ(ptsloc[2].X,ptsloc[2].Y,lvl.Elevation)]
t=Transaction(doc,"create foot")
t.Start()
[doc.Create.NewFamilyInstance(n, fs, lvl, StructuralType.Footing) for n in npts]
t.Commit()
OUT = npts
What do the properties of the new footings look like? If they’re assigned to the level and offset by the elevation then they’d be off by that amount.
That’s what @christian.stan is trying to explain. If your foundation level is at -5’ then you either want to place your footings at that level with no offset or at ground level with the -5’ offset. Right now you’re placing them at the foundation level and adjusting the z offset to the same value.