# Python, Get elevation view from elevationMarker

**URL:** <https://forum.dynamobim.com/t/python-get-elevation-view-from-elevationmarker/53970>\
**Category:** Revit\
**Tags:** python\
**Created:** [August 12, 2020, 9:56am UTC](https://forum.dynamobim.com/t/python-get-elevation-view-from-elevationmarker/53970 "2020-08-12T09:56:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alisder\_Brown](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alisder_brown/32/14995_2.png) [@Alisder\_Brown](https://forum.dynamobim.com/u/Alisder_Brown)\
**Post date:** [August 12, 2020, 9:56am UTC](https://forum.dynamobim.com/t/python-get-elevation-view-from-elevationmarker/53970/1 "2020-08-12T09:56:11Z")

</div>

Hi All,

I’m currently using a Python node created by [jeremy@learndynamo.com](mailto:jeremy@learndynamo.com), which I have edited to suit my needs (Create one elevation marker with all 4 elevations turned on). The output I get from this script is the Elevation MArker, but I am looking to get a list out of all the individual elevation views created. Please see the script below of what I’m using. Any advice would be appreciated. I do have a basic \> intermediate knowledge of Python. Thanks in advance!

```
#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]
points = 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)
	
	for ind, point in enumerate(points):
	
		#Retrieve the mid point of model lines and get X,Y.		
		modelMP = modelPoints[ind].ToXyz()
		modelMPX = modelMP.X
		modelMPY = modelMP.Y
		
		#Retrieve individual lines of crop window.		
		cropLines = cropCurves[ind]
		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)
		ele = eleMarker.CreateElevation(doc, doc.ActiveView.Id , 1)
		ele = eleMarker.CreateElevation(doc, doc.ActiveView.Id , 2)
		ele = eleMarker.CreateElevation(doc, doc.ActiveView.Id , 3)
		lst.append(eleMarker)
				#	
		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)
					
		except:
			pass
			
	TransactionManager.Instance.TransactionTaskDone()
	
	OUT = lst
	
else:

	OUT = "Set toggle to TRUE"
```

---

<div class="post-metadata">

**Author:** ![Daniel\_Woodcock1](https://avatars.discourse-cdn.com/v4/letter/d/58f4c7/32.png) [@Daniel\_Woodcock1](https://forum.dynamobim.com/u/Daniel_Woodcock1)\
**Post date:** [August 13, 2020, 4:16pm UTC](https://forum.dynamobim.com/t/python-get-elevation-view-from-elevationmarker/53970/2 "2020-08-13T16:16:03Z")

</div>

Create a new array just after `if toggle == True`, say…

`elevations = []`

And where you have `ele = eleMarker.CreateElevation()`, store the returned ViewSection in your elevations array. You can do this simply by doing…

`elevations.append(eleMarker.CreateElevation(doc, doc.ActiveView, index))`

And then `OUT = lst, elevations`

---

<div class="post-metadata">

**Author:** ![robert12546358](https://avatars.discourse-cdn.com/v4/letter/r/c5a1d2/32.png) [@robert12546358](https://forum.dynamobim.com/u/robert12546358)\
**Post date:** [January 20, 2021, 4:43am UTC](https://forum.dynamobim.com/t/python-get-elevation-view-from-elevationmarker/53970/3 "2021-01-20T04:43:47Z")

</div>

I set script as above post, then i get a new error of code as below snip.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/8/187dd22e8688887b674615fb138d448c7ac3d65b.png)
