Create Multiple Elevation Views From Filtered Wall Types In A Linked Revit Model

I want to create exterior building elevation views in my Revit model based on walls of a certain type in a linked Revit model, then place those views on sheets. Is there a way to do this?

I tried filtering the walls but got stuck at the “get location from element id” since element ID’s can’t be pulled from a linked model.

I would also like to avoid copying & pasting the walls, but if it’s unavoidable, I understand.

Hello Mel!!

You can always try and get the Geometry off of the element then from that geometry get the location on the project if thats what you want, just remember that location for walls in revit returns as a Line which determines the length of the wall. Ive always found elevations to be a little tricky, worked on a similar project a few months ago an decided to work with sections rather than elevations.

1 Like

Hi @mbolinSTBLH and Welcome, yes its possible even on linked elements, but not with OOTB gues its only support sections…for create viewports we have ootb for that…
Revit_wTpPQnOTMi

import clr
import math
from Autodesk.Revit.DB import *
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

def get_face_loop(w, t):
    try:
        f_ref = HostObjectUtils.GetSideFaces(w, ShellLayerType.Interior)[0]
        f = w.GetGeometryObjectFromReference(f_ref)
        loop = f.GetEdgesAsCurveLoops()[0]
        return CurveLoop.CreateViaTransform(loop, t)
    except:
        return None


wall_inputs = UnwrapElement(IN[0])
link_instances = UnwrapElement(IN[1])
offset_distance = IN[2]
rotation_tweak = IN[3]


if isinstance(wall_inputs, list):
    walls_list = wall_inputs
else:
    walls_list = [wall_inputs]

if isinstance(link_instances, list):
    links_list = link_instances
else:
    links_list = [link_instances]

vft = next(v for v in FilteredElementCollector(doc).OfClass(ViewFamilyType) if v.ViewFamily == ViewFamily.Elevation)

results = []

TransactionManager.Instance.EnsureInTransaction(doc)
try:
    for i, w_raw in enumerate(walls_list):
        if w_raw is None: continue
        
        l_obj = links_list[i] if i < len(links_list) else links_list[0]
        if l_obj is None: continue

        if hasattr(w_raw, "LinkedElementId"):
            wall = l_obj.GetLinkDocument().GetElement(w_raw.LinkedElementId)
        else:
            wall = w_raw

        if wall is None or not hasattr(wall, "Orientation"): continue

        xf = l_obj.GetTotalTransform()
        w_norm = xf.OfVector(wall.Orientation).Normalize()
        mid = xf.OfPoint(wall.Location.Curve.Evaluate(0.5, True))
        pt = mid.Add(w_norm.Multiply(offset_distance))

        marker = ElevationMarker.CreateElevationMarker(doc, vft.Id, pt, 100)
        view = marker.CreateElevation(doc, doc.ActiveView.Id, 0)

        if view:
            look = w_norm.Negate()
            ang = XYZ.BasisX.AngleOnPlaneTo(look, XYZ.BasisZ) + math.radians(rotation_tweak)
            axis = Line.CreateBound(pt, pt.Add(XYZ.BasisZ))
            ElementTransformUtils.RotateElement(doc, marker.Id, axis, ang)

            view.CropBoxActive = True
            view.CropBoxVisible = True
            loop = get_face_loop(wall, xf)
            if loop:
                try: 
                    view.GetCropRegionShapeManager().SetCropShape(loop)
                except: 
                    pass
            
            results.append(view)

    OUT = results
except Exception as e:
    OUT = str(e)
finally:
    TransactionManager.Instance.TransactionTaskDone()
2 Likes