I found this topic once placing Elevation Marker and have the face a certain direction
(i’ll try to find the original topic.
It uses this Python, but sometimes one Elevation Marker faces the wrong direction. Any idea why? @c.poupin maybe?
import clr
import System
from System.Collections.Generic import List
# Add Revit API References
clr.AddReference('RevitAPI')
clr.AddReference("RevitServices")
clr.AddReference("RevitNodes")
import RevitServices
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
import Autodesk
import Autodesk.Revit.DB as DB
from Autodesk.Revit.DB import *
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from math import atan2
# Document reference
doc = DocumentManager.Instance.CurrentDBDocument
# ------------------------------
# Inputs
# ------------------------------
toggle = IN[0] # Boolean toggle to run
points = [UnwrapElement(pt) for pt in IN[1]] # Elevation marker positions
modelPoints = [UnwrapElement(mp) for mp in IN[2]] # Model reference points
viewType = UnwrapElement(IN[3]) # ViewFamilyType for elevation
# Normalize input format for multi-point runs
if not isinstance(points[0], list):
points = [points]
modelPoints = [modelPoints]
# ------------------------------
# Execution
# ------------------------------
created_views = [[] for _ in range(len(points))] # One list per group/scope box
if toggle:
TransactionManager.Instance.EnsureInTransaction(doc)
for i in range(len(points)):
pts = points[i]
mps = modelPoints[i]
for ind, point in enumerate(pts):
try:
# Get XYZ positions
modelMP = mps[ind].ToXyz()
elevationPT = point.ToXyz()
# Vector direction for rotation
elptRotate = XYZ(elevationPT.X, elevationPT.Y, elevationPT.Z + 100)
axis = Line.CreateBound(elevationPT, elptRotate)
angle = atan2(elevationPT.Y - modelMP.Y, elevationPT.X - modelMP.X)
# Create elevation marker and view
eleMarker = ElevationMarker.CreateElevationMarker(doc, viewType.Id, elevationPT, 100)
eleView = eleMarker.CreateElevation(doc, doc.ActiveView.Id, 0)
# Rotate the marker to face the model point
ElementTransformUtils.RotateElement(doc, eleMarker.Id, axis, angle)
# Add the view to the correct group
created_views[i].append(eleView)
except Exception:
continue
TransactionManager.Instance.TransactionTaskDone()
# ------------------------------
# Outputs
# ------------------------------
OUT = created_views if toggle else []
It may be that there is invalid data, or file setup, which is causing the blocker. Without a dataset to test line and view by view it’s really tough to know why things are reacting the way they are. Cropbox rotation, view rotation, view orientation, and more will all play a role in ‘why’.
In these cases debugging is painful, but if you go about it systematically you can often identify the issue.
Make a new view of the same class as one of the failing views and see if the brand new view behaves incorrectly. Make sure no template, extents, or other info is set - we want this as close to a ‘raw’ view from Revit as possible.
If so, check for project wide settings which impact orientation such as true north angle.
If not start to look at configuration differences between the new ‘raw’ view and the project specific one which impact orientation. Scope box, crop region, north orientation, etc. Turn things on 1x1 and re-run the tool until you find the ‘problematic setting’.
Once you have the setting identified, look to append an additional transform in the code to deal with whatever alterations the property of the view is applying.
It does not work and works in the same Project on the same View,
using the same Scope Box etc.
Only difference is i stripped the project from the Geometry (Families) so i was left with just the
Scope Boxes, Levels, Grids, Views etc.
So for now people can let this rest till i found the culprit.