Create building sections using reference lines/detail lines

I am trying to create a script that will use lines to create sections using python


viewFamilyTypes = (FilteredElementCollector(doc).OfClass(ViewFamilyType).ToElements())
vftLst = []
for vf in viewFamilyTypes:
  if vf.LookupParameter("Type Name").AsString() == secTypeName:
  vftLst.append(vf.Id)

section1_create = ViewSection.CreateSection(doc, vftLst[0], bbox_sections[0])

I am facing issues with the bbox_sections(Bounding Box)
Below is the Bounding Box constructor

new_boundingbox = []
for min_pt, max_pt in zip(min_pts, moved_max_pts):
    temp = BoundingBoxXYZ()
    temp.Min = XYZ((min_pt.X) / 304.8, (min_pt.Y) / 304.8, (min_pt.Z) / 304.8)
    temp.Max = XYZ((max_pt.X) / 304.8, (max_pt.Y) / 304.8, (max_pt.Z) / 304.8)

    new_boundingbox.append(temp)

bboxOffset_floorPlan = UnitUtils.ConvertToInternalUnits(750, UIunit)
scaled_bounding_box = []

for bbox in new_boundingbox:
    temp = OffsetBBox(bbox, bboxOffset_floorPlan)
    scaled_bounding_box.append(temp)

I need some help with the transformation of the bounding box, which throws an exception:

The BoundingBoxXYZ is not appropriate for detail views. The basis vectors of must be unit length and orthonormal. The near and far bound offsets cannot be reversed or too close to each other. MinEnabled and MaxEnabled must be set to true for all three directions

1 Like

Great, share how far you’ve got in a dyn and identify the key issues you’re facing so people can hep you.

So I managed to figure out the Solution, which needed some inputs based on the API,

ViewSection.CreateSection(doc, viewfamilytype, sectionbox)

I built the following function using a couple of references, the catch was to feed the (mid_pt, lineDir, viewdir, minpt, maxpt) correctly, so I created another function which supplies these values to the function below.

def CreateSectionUsingBBox(mid_pt, lineDir, viewdir, minpt, maxpt):

    viewFamilyTypes = FilteredElementCollector(doc).OfClass(ViewFamilyType).ToElements()
    vftLst = []
    for vf in viewFamilyTypes:
        if vf.LookupParameter("Type Name").AsString() == secTypeName:
            vftLst.append(vf.Id)

    t = Transform.Identity
    t.Origin = XYZ((mid_pt.X) / 304.8, (mid_pt.Y) / 304.8, (mid_pt.Z) / 304.8)
    t.BasisX = XYZ((lineDir.X), (lineDir.Y), (lineDir.Z))
    t.BasisY = XYZ.BasisZ
    t.BasisZ = XYZ((viewdir.X), (viewdir.Y), (viewdir.Z))

    sectionBB = BoundingBoxXYZ()
    sectionBB.Transform = t
    sectionBB.Min = XYZ((minpt.X) / 304.8, (minpt.Y) / 304.8, (minpt.Z) / 304.8)
    sectionBB.Max = XYZ((maxpt.X) / 304.8, (maxpt.Y) / 304.8, (maxpt.Z) / 304.8)

    SectionView = ViewSection.CreateSection(doc, vftLst[0], sectionBB)

    return SectionView

2 Likes