Create elevation view by element

I’m trying to create a elevation view by element.
In my specific case, i select a specific element in revit (a wall) and i want to built a elevation view that crops to the extents of this wall.

I’ve seen this article, it teaches how to create elevation view by model curves, i tryed to adapt it to my context but it did not work. Can anybody please help me?

The error i get is the following image

Elevation View Generator.dyn (39.7 KB)

Thank you all in advance.

1 Like

Hi,

The python script expects a list of Elevation Marker Points and not a single point. (Select multiple walls)

The downloaded .dyn seems to work.
LearnDynamo_Module_2 (dynamo 2.0).dyn (87.4 KB)

1 Like

Is there a way to adapt that for a single one?

It works but with one or several walls the result doesn’t seem to be perfect.
Did you already try the ViewSection.ByLine node in Data-Shape or the Create Element View node in BIM4Struc ?

#Copyright(c) 2016 www.Learndynamo.com 
#Please contact at jeremy@learndynamo.com

import clr
clr.AddReference('RevitAPI')
clr.AddReference("RevitServices")
clr.AddReference("RevitNodes")
import RevitServices
import Revit
import Autodesk
from Autodesk.Revit.DB import *
from math import *

clr.ImportExtensions(Revit.GeometryConversion)

from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

toggle = IN[0]
point = UnwrapElement(IN[1])
modelPoints = UnwrapElement(IN[2])
cropCurves = UnwrapElement(IN[3])
viewType = UnwrapElement(IN[4])

lst = []

#Get Family View Type
vft = 0
collector = FilteredElementCollector(doc).OfClass(ViewFamilyType).ToElements()

#eleViews = []
for i in collector:
	if i.ViewFamily == ViewFamily.Elevation:		
		vft = i.Id
		break
 
if toggle == True:
	
	TransactionManager.Instance.EnsureInTransaction(doc)
	

	
		#Retrieve the mid point of model lines and get X,Y.		
	modelMP = modelPoints.ToXyz()
	modelMPX = modelMP.X
	modelMPY = modelMP.Y
		
		#Retrieve individual lines of crop window.		
	cropLines = cropCurves
	l1 = cropLines[0].ToRevitType()
	l2 = cropLines[1].ToRevitType()
	l3 = cropLines[2].ToRevitType()
	l4 = cropLines[3].ToRevitType()
					
		# Create a line in the z-Axis for elevation marker to rotate around.			
	elevationPT = point.ToXyz()
	elptRotate = XYZ(elevationPT.X, elevationPT.Y, elevationPT.Z+100)
	ln = Line.CreateBound(elevationPT, elptRotate)

		#Calculate the angle between Model Mid Point and Elevation Point.
	elevationPTY = elevationPT.Y
	elevationPTX = elevationPT.X							
	combY = elevationPTY-modelMPY
	combX = elevationPTX-modelMPX			
	ang = atan2(combY, combX)

		#Create elevation marker and elevation in position 0.
	eleMarker = ElevationMarker.CreateElevationMarker(doc, viewType.Id, elevationPT, 100)
	ele = eleMarker.CreateElevation(doc, doc.ActiveView.Id , 0)
		
		#Rotate elevation marker towars model line.
	ElementTransformUtils.RotateElement(doc, eleMarker.Id, ln, ang)
		
		#	
	crManager = ele.GetCropRegionShapeManager()
		#crShape = crManager.GetCropRegionShape()

	newCurveLoop = []
	newCurveLoop.Add(l1)
	newCurveLoop.Add(l2)
	newCurveLoop.Add(l3)
	newCurveLoop.Add(l4)
			
	cLoop = CurveLoop.Create(newCurveLoop)

	try:			
		crManager.SetCropRegionShape(cLoop)
		lst.append("Elevation Created")
		
	except:
		pass
		lst.append("Missed Elevation")

	TransactionManager.Instance.TransactionTaskDone()
	
	OUT = lst
	
else:

	OUT = "Set toggle to TRUE"
1 Like

I did, but it creates a section view. In my case, what i really need is an elevation view.
Thanks for your help!

Edit: I haven’t tryed the one from data-shapes, but looking at it now… it doesnt seems to work

I used your code and it doesn’t work with any walls.
I used the node ElevationMarker.CreateElevation Marker from the Rhythm package and it created a marker with the view. The problem is that i canot update the view crop region through dynamo. Is there a way to do so?

Thanks !

In this case, use this dyn with the updated python script.

LearnDynamo_Module_2 (dynamo 2.0) V2.dyn (88.2 KB)

Thanks for you support man.
But unfortunately, even this new code keeps returning me the message Missed elevation

Me too, but the elevation view is still created at the correct location.

In some cases it is… in most it is not created. When i use the node ElevationMarker.CreateElevationMarker from the rhythm package it always creates the elevation at the correct spot. There is a node from the clockWork package called ElevationMarker.Views. with him i could get the views associated to the elevation marker. He is not currently working. His code is this one:

import clr

clr.AddReference(‘RevitAPI’)
from Autodesk.Revit.DB import *

clr.AddReference(“RevitNodes”)
import Revit
clr.ImportExtensions(Revit.Elements)

def GetElevationMarkerView(item):
val =
if hasattr(item, “HasElevations”):
if item.HasElevations():
for i in range(item.MaximumViewCount):
view = item.Document.GetElement(item.GetViewId(i))
if view: val.append(view)
return val

items = UnwrapElement(IN[0])

if isinstance(IN[0], list): OUT = [GetElevationMarkerView(x) for x in items]
else: OUT = GetElevationMarkerView(items)

Any tip on how to fix that?

I suggest you create a new topic with your new question (ElevationMarker.Views node) and link it to this page.
The original subject with the error in the python script is resolved even though your elevation creation problem remains the same.
For now, I do not have time to edit other scripts.

1 Like

Thanks for your support.
That’s what i’ll do.

Hi, I recreated this in 1.3 but I get this error.
image
Any advice ?
Cheers

Hi @simoneavellini , can you show what you have in line 46 and what the inputs look like?
It seems you need to go one (or more) step deeper into the list, to be able to extract the xyz attribute from the point and not the list of points.