But i try to get it to work for multiple Scope Boxes. I think something in the Python needs to be change for that (?). I already fiddled with Levels and such, but it wasn’t that simple .
Best to share a screenshot with what you have and what you’re seeing. If it’s just a matter of going from one scope box to many then you should just need another for loop.
Only running into this problem and i am not sure what i am missing.
It works when i use the script for a single Scope Box.
They Elevation Markers Scope Boxes get greyed out on placement.
Dunno why. I guess something in de Python code?
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 []