IfcExportUtils

solved

Could you share the python code? I’m interested in the curves around windows in walls, is that what you get from that method?

the solution:
bounding = the resulting bounding loop
doc = the active document
element = the wall element
as I used:
openingIds = element.FindInserts(True,True,True,True)
results in a list of all openingIds for each wall.
as the openings are received as ElementIds the elements have to be extracted from the Ids using doc.GetElement(openingId)

orient = the direction of the vector intersecting the wall

the python command:

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

Thank you, I’m missing a reference or something:

import clr

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.IFC import *

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

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

doc = DocumentManager.Instance.CurrentDBDocument

#Preparing input from dynamo to revit
wall = UnwrapElement(IN[0])
familyInst = UnwrapElement(IN[1])
vec = IN[2].ToXyz()

OUT = ExporterIFCUtils.GetInstanceCutoutFromWall(doc,wall,familyInst,vec)

ok, thought that was obvious :wink:
here the modules:

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

It should have been obvious yes, looks like it’s an issue with my revit 2017 install. I got it working in 2016. Thank you very much for your help.

OK I got it working:

I forgot to reference the RevitAPIIFC.dll, and the vector needed to be in a StrongBox container in rvt 2017

import clr

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

clr.AddReference('RevitAPIIFC')
from Autodesk.Revit.DB.IFC import *

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

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

doc = DocumentManager.Instance.CurrentDBDocument

#Preparing input from dynamo to revit
wall = UnwrapElement(IN[0])
familyInst = UnwrapElement(IN[1])
vec = clr.StrongBox[XYZ](wall.Orientation)

#Get curves
curves=ExporterIFCUtils.GetInstanceCutoutFromWall(doc,wall,familyInst,vec) 

#Convert to dybmo geometry:

OUT = [curve.ToProtoType(True) for curve in curves]
2 Likes

einar, the strong box container was already required with revit 2016.
actually there are two ways to achieve the strongbox container:
the first solution is the one i suggested.
bounding, orient =I.ExporterIFCUtils.GetInstanceCutoutFromWall(doc, element, doc.GetElement(openingId),)
the strong box container is constructed as a tuple bounding, orient
so the same is achieved as with your suggestion:
vec = clr.StrongBox[XYZ](wall.Orientation)

Thank you for the explanation Peter. I’m not sure that I completely understand how the StrongBox works, but I’m happy as long as it works.

For anyone that’s interested, here’s the code that returns all opening curves from a wall:

import clr

from clr import StrongBox

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

clr.AddReference('RevitAPIIFC')
from Autodesk.Revit.DB.IFC import *

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

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

doc = DocumentManager.Instance.CurrentDBDocument

#Preparing input from dynamo to revit
wall = UnwrapElement(IN[0])

#Get direction and openings from wall:
vec = StrongBox[XYZ](wall.Orientation)
openingIds = wall.FindInserts(True,True,True,True)

#Get curves and convert to Dynamo geometry:
openingCurves = []
for id in openingIds:
	opn = doc.GetElement(id)
	curves = ExporterIFCUtils.GetInstanceCutoutFromWall(doc,wall,opn,vec) 
	openingCurves.append([curve.ToProtoType(True) for curve in curves])
#Convert to dybmo geometry:

OUT = openingCurves

1 Like

same for me, i just found out in reading ironpython help, that the strong box in python may be achieved with a tuple for out and in. that is what i did.
using the clr.StrongBox maybe is preferable as more straightforward aligning with the c# coding
cheers

Was STRUGGLING with this - didn’t realize I needed to add RevitAPIIFC reference…thanks for the assist!