# Creating Openings in dynamo with python

**URL:** <https://forum.dynamobim.com/t/creating-openings-in-dynamo-with-python/48464>\
**Category:** Revit\
**Tags:** revit, python, dynamo\
**Created:** [March 25, 2020, 9:58am UTC](https://forum.dynamobim.com/t/creating-openings-in-dynamo-with-python/48464 "2020-03-25T09:58:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rosina.Hyatt](https://avatars.discourse-cdn.com/v4/letter/r/ecccb3/32.png) [@Rosina.Hyatt](https://forum.dynamobim.com/u/Rosina.Hyatt)\
**Post date:** [March 25, 2020, 9:58am UTC](https://forum.dynamobim.com/t/creating-openings-in-dynamo-with-python/48464/1 "2020-03-25T09:58:28Z")

</div>

I am trying to create openings in walls where ducts pass through them. I have been using this code I found however it does not work, it find the correct locations but revit error says cannot create openings. is there anyway to modify this code?  
[Forum 1|555x500](https://forum.dynamobim.com/uploads/short-url/XAPCO7wToXluKwZCPYPvHAouDg.png)

 ![Forum](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/1/b/1ba91cff52fbfeb9a676e04c1ebaf27929d68038.png)

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

clr.AddReference(“RevitServices”)  
import RevitServices  
from RevitServices.Persistence import DocumentManager  
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument  
openings =

walls = IN[0]  
points = IN[1]  
direction = IN[2]  
width = IN[3]  
height = IN[4]

for idx in range(0,len(walls)):  
if direction == ‘x’:  
ULX=(points[idx]).X - width[idx]/2  
ULY=(points[idx]).Y  
ULZ=(points[idx]).Z + height[idx]/2

```
	UL = XYZ(ULX/304.8,ULY/304.8,ULZ/304.8)
	
	DRX=(points[idx]).X + width[idx]/2
	DRY=(points[idx]).Y
	DRZ=(points[idx]).Z - height[idx]/2
	
	DR = XYZ(DRX/304.8,DRY/304.8,DRZ/304.8)
else:
	ULX=(points[idx]).X
	ULY=(points[idx]).Y - width[idx]/2
	ULZ=(points[idx]).Z + height[idx]/2
		
	UL = XYZ(ULX/304.8,ULY/304.8,ULZ/304.8)
	
	DRX=(points[idx]).X
	DRY=(points[idx]).Y + width[idx]/2
	DRZ=(points[idx]).Z - height[idx]/2
	
	DR = XYZ(DRX/304.8,DRY/304.8,DRZ/304.8)

TransactionManager.Instance.EnsureInTransaction(doc)
opening = doc.Create.NewOpening(UnwrapElement(walls[idx]),UL,DR)
doc.Regenerate()
TransactionManager.Instance.TransactionTaskDone()
openings.append(opening)

```

OUT = openings
