Get HostElement of a BoundaryConditions Element in Python

Hello,

I am new to using the Revit API and would like to get the HostElement of a BoundaryConditions Element in Python. Here is what I tried:

grafik

import clr
clr.AddReference(‘ProtoGeometry’)
from Autodesk.DesignScript.Geometry import *
import clr
clr.AddReference(‘ProtoGeometry’)
from Autodesk.DesignScript.Geometry import *

Import RevitNodes

clr.AddReference("RevitNodes")
import Revit

Import Revit elements

from Revit.Elements import *

Import DocumentManager

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager

import System

myBc = IN[0]

OUT = myBc.LevelId

Any tips on how to import the right ‘parts’ of the API?

Edit: I am using Revit 2016 and Dynamo 1.3

Hi,

You can add the lines :

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

P.S : I’ve no idea if your script will work.

Hi Alban,

thank you for your answer, unfortunately I still get the same warning (I tried it with “LevelId” instead of “HostElement” in the original post)

You need to import Autodesk.Revit.DB.Structure, and unwrap the element. Read about unwrapping and more here: https://github.com/DynamoDS/Dynamo/wiki/Python-0.6.3-to-0.7.x-Migration

2 Likes

@Einar_Raknes thank you, that helps alot!