Newopening method

Hi,

I am trying to use the newopening method for wall in a python script block. I input wall elements , start point and end point of the rectangle. When I run it python messages that a “level is expected”. So actually I noticed the newopening for shaft is exactly same method. I do not know how to procede. Please anyone can suggest me?

Thanks

PS. I am quite new to this world so i apologize for any stupid thing that I have done!

here the code

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 = UnwrapElement(IN[0])
points = IN[1]

for idx in range(0,len(walls)):
StartPoint = (points[idx][0])
EndPoint = (points[idx][2])

TransactionManager.Instance.EnsureInTransaction(doc)
opening = doc.Create.NewOpening(walls[idx],StartPoint,EndPoint)
TransactionManager.Instance.TransactionTaskDone()
openings.append(opening)

OUT = openings

Hi Emanuele

Python is selecting the wrong overload of NewOpening. You need to give it a hint, something like:

	opening = doc.Create.NewOpening.Overloads.Functions[3](walls[idx],StartPoint,EndPoint)

I’m using the [3] index because this is the 4th overload listed in the Revit API Help. See Daren’s explanations for more:


Hi David,

Really thanks for you message!

Just another question, can you suggest me any book or whatever to study deeper python and also revit API?

Thanks

2 Likes

Thank you so much David.it will be very useful.