I am trying to create window elevations.
Here is an example using C# which I am trying to implement with pyRevit.
https://forums.autodesk.com/t5/revit-api-forum/elevationmarker-does-not-rotate-180-deg/td-p/8010880
I can not get the view to rotate:
Part of code that uses the ElementTransformUtils.RotateElement
eleMarker = ElevationMarker.CreateElevationMarker(doc,viewFamilyTypeId,origin,initialViewScale)
start_point = win_origin
lineAsAxis = Line.CreateBound(start_point, XYZ(start_point.X,start_point.Y, start_point.Z + 1));
print("Marker:{} line:{} angle:{}".format(eleMarker.Id,lineAsAxis,angle))
ElementTransformUtils.RotateElement(doc,eleMarker.Id,curve,angle)
Full code block:
# -*- coding: utf-8 -*-
__title__ = "Elevate Windows"
__doc__ = """
_____________________________________________________________________
Elevate Windows
_____________________________________________________________________
Credit to: Erik Frits for his tutorial for starter data"""
from Autodesk.Revit.DB import *
from pyrevit import forms
uidoc = __revit__.ActiveUIDocument
doc = __revit__.ActiveUIDocument.Document #type: Document
app = __revit__.Application
from math import radians
windows = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Windows).WhereElementIsNotElementType().ToElements()
dict_windows = {}
for win in windows:
family_name = win.Symbol.Family.Name
type_name = Element.Name.GetValue(win.Symbol)
key_name = '{}_{}'.format(family_name, type_name)
host = win.Host
if type(host) == Wall:
dict_windows[key_name] = win
else:
print('Unsupported Host for Window: {} [{}]'.format(key_name, win.Id))
# Transaction to Modify Project
t = Transaction(doc, 'Generate Window Sections')
t.Start()
for window_name, window in dict_windows.items():
try:
print("Processing " + window_name)
win_origin = window.Location.Point #type: XYZ
print("Location: {}".format(win_origin))
# Calculate Vector based on the Wall
host_wall = window.Host
curve = host_wall.Location.Curve #type: Curve
pt_start = curve.GetEndPoint(0) #type: XYZ
pt_end = curve.GetEndPoint(1) #type: XYZ
vector = pt_end - pt_start #type: XYZ
#3️ Get Window Size
win_width = window.Symbol.get_Parameter(BuiltInParameter.GENERIC_WIDTH).AsDouble()
win_height = window.Symbol.get_Parameter(BuiltInParameter.WINDOW_HEIGHT).AsDouble() # ADJUST TO YOUR PARAMETERS!
print("Window Width: {} Window Height {}".format(win_width,win_height) )
cm_40 = UnitUtils.ConvertToInternalUnits(40, UnitTypeId.Centimeters) #40cm (Revit API takes unit in FEET!)
win_depth = cm_40
offset = cm_40
#6️Create Section View
view_types = FilteredElementCollector(doc).OfClass(ViewFamilyType).ToElements()
view_types_ele = [vt for vt in view_types if vt.ViewFamily == ViewFamily.Elevation]
#view_elevation_type = [vt for vt in view_types_ele if vt.get_Parameter(BuiltInParameter.ALL_MODEL_TYPE_NAME).AsString()=="B5 90 Window & Door Elevation"]
viewFamilyTypeId=view_types_ele[0].Id
origin = win_origin
initialViewScale=50
plan_view = doc.ActiveView
angle = radians(10)
#https://forums.autodesk.com/t5/revit-api-forum/elevationmarker-does-not-rotate-180-deg/td-p/8010880
eleMarker = ElevationMarker.CreateElevationMarker(doc,viewFamilyTypeId,origin,initialViewScale)
start_point = win_origin
lineAsAxis = Line.CreateBound(start_point, XYZ(start_point.X,start_point.Y, start_point.Z + 1));
print("Marker:{} line:{} angle:{}".format(eleMarker.Id,lineAsAxis,angle))
ElementTransformUtils.RotateElement(doc,eleMarker.Id,curve,angle)
ele_west = eleMarker.CreateElevation(doc,plan_view.Id,0)
except:
import traceback
print('---\n ERROR:')
print(traceback.format_exc())
t.Commit() #