Door/Window Areas

Door/Window Areas

PhillipM
Advocate Advocate
9,339 Views
29 Replies
Message 1 of 30

Door/Window Areas

PhillipM
Advocate
Advocate

HI guys.

 

I'm needing to know the cut area's of windows and doors in a wall. I thought this would be a simple matter of grabbing the BIP "HOST_Area_Computed" as with my testing that was returning the correct area.  It turns out that this is not the case from further testing.

 

PLease refer to the attached RVT file with two doors inserted into a wall.  They look similar but one is reporting through Revit Lookup 4m2 and the other 2m2.

 

Why is this?  What actually is "HOST_Area_Computed" reporting?  and what is the most reliable way of getting the cut area of windows and doors?

 

Regards

 

Phillip Miller

0 Likes
Accepted solutions (2)
9,340 Views
29 Replies
Replies (29)
Message 21 of 30

office
Enthusiast
Enthusiast

jeremy, thanks for your reply!

 

my solution went like:

 

for i in openingIds:
				try:
					bounding, orient = I.ExporterIFCUtils.GetInstanceCutoutFromWall(doc, element, doc.GetElement(i),)
					print "success"
				except:
					
					print (" failed for wall %s and opening %s" %(element.Id, i))

 

 

cheers peter

 

0 Likes
Message 22 of 30

jeremytammik
Autodesk
Autodesk

Dear Peter,

 

Thank you for sharing that.

 

I summarised your solution on The Building Coder, and also point out a generic link with a similar answer:

 

http://thebuildingcoder.typepad.com/blog/2016/07/retrieving-a-c-out-argument-value-in-python.html#2

 

Cheers,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 23 of 30

Anonymous
Not applicable

Hi Peter,

 

I am trying to implement your solution in a Dynamo Python node but it fails with "AttributeError: attribute 'ExporterIFCUtils' of 'namespace#' object is read-only" which I think means I am not using the reference to IFCUtils properly... but I am not sure of that.

 

Can you show how you import Autodesk.Revit.DB.IFC to use it with python?

Also, are you coding for Dynamo or using the revit python shell within Revit?

 

Thanks

0 Likes
Message 24 of 30

office
Enthusiast
Enthusiast

for the import:

 

from Autodesk.Revit.DB.IFC import *
I = Autodesk.Revit.DB.IFC

 

and later:

doc =  __revit__.ActiveUIDocument.Document

#element = wall element collected with filter

orient = element.Orientation

 

bounding, orient = I.ExporterIFCUtils.GetInstanceCutoutFromWall(doc, element, doc.GetElement(i),)

 

#-----------------

best peter

 

0 Likes
Message 25 of 30

Anonymous
Not applicable

Thanks for the quick response, Peter.

 

I cannot make it work at all. whenever I assign "I":

 

from Autodesk.Revit.DB.IFC import *
I = Autodesk.Revit.DB.IFC

Revit Python shell crashes. Have tried with Macros and same result...

 

I must be missing something somewhere but am clueless now... But If I can't get past loading IFC to use IFCUtils I don't see how to make it work.

 

Thanks again!

 

Ivan

0 Likes
Message 26 of 30

office
Enthusiast
Enthusiast
import clr
import math
clr.AddReference('RevitAPI') 
clr.AddReference('RevitAPIUI') 
clr.AddReference('REVITAPIIFC')
from Autodesk.Revit.DB import * 
import Autodesk
from Autodesk.Revit.DB import *
from System.Collections.Generic import *
from Autodesk.Revit.DB.IFC import *
I = Autodesk.Revit.DB.IFC

uidoc = __revit__.ActiveUIDocument
doc = __revit__.ActiveUIDocument.Document
app = __revit__.Application

cl = FilteredElementCollector(doc)
elements = cl.OfCategory( BuiltInCategory.OST_Walls ).WhereElementIsNotElementType().ToElements()
t= Transaction(doc,"netground")
t.Start()
for element in elements:
	orient = element.Orientation
	openingIds=element.FindInserts(True,True,True,True)
	if openingIds.Count >0:
		for i in openingIds:
			opening = doc.GetElement(i)
			try:
				bounding, orient = I.ExporterIFCUtils.GetInstanceCutoutFromWall(doc, element, opening,)
				loops = List[CurveLoop]()
				loops.Add(bounding)
				area = I.ExporterIFCUtils.ComputeAreaOfCurveLoops(loops)
				print (area)
			except:
				pass
t.Commit()

this code is working on my side.

i am using pyRevit as python enviroment.

https://github.com/eirannejad/pyRevit

 

i suppose the problem might be to set the paths for python libraries correctly when in python shell

Message 27 of 30

Anonymous
Not applicable

Solved!. To be able to use IFCUtils from a python node in Dynamo I changed your code like this:

 

# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

uidoc = DocumentManager.Instance.CurrentUIApplication
doc = DocumentManager.Instance.CurrentDBDocument
app = uidoc.Application

Now it properly loads the references from the API and it works. This is probably trivial but beeing a rookie took me a bit to figure out.

 

Thanks for your help Kop!.

0 Likes
Message 28 of 30

Anonymous
Not applicable
BTW, the areas are reported in sq feet... conversion is needed for metric system.
0 Likes
Message 29 of 30

office
Enthusiast
Enthusiast

To clarify: 

1) I am working with the python shell, so no Dynamo specific coding is implemented in the sample.

2) of course all units returned from revit are not metric. conversion will always be necessary for Non US 😉 users.

best peter

0 Likes
Message 30 of 30

office
Enthusiast
Enthusiast

To clarify: 

1) I am working with the python shell, so no Dynamo specific coding is implemented in the sample.

2) of course all units returned from revit are not metric. conversion will always be necessary for Non US users which is appx. 80% of the revit users as I guess?

best peter

0 Likes