# Placing a Column with Python Node

**URL:** <https://forum.dynamobim.com/t/placing-a-column-with-python-node/107484>\
**Category:** Developers\
**Tags:** python\
**Created:** [January 24, 2025, 3:42pm UTC](https://forum.dynamobim.com/t/placing-a-column-with-python-node/107484 "2025-01-24T15:42:54Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![donny.hoogendorp](https://avatars.discourse-cdn.com/v4/letter/d/9e8a1a/32.png) [@donny.hoogendorp](https://forum.dynamobim.com/u/donny.hoogendorp)\
**Post date:** [January 24, 2025, 3:42pm UTC](https://forum.dynamobim.com/t/placing-a-column-with-python-node/107484/1 "2025-01-24T15:42:54Z")

</div>

Hey Guys,

I’m trying to place a Column by using the dynamo node. While doing so i keep encountering this error:

```auto
Autodesk.Revit.Exceptions.InvalidOperationException: Instance of a level-based family cannot be created without a valid reference level.
at ?A0xa6a4641f.updateInstParamsForLevelRefFamily(ADocument* pADoc, FamilyInstance* pFamilyInstance, Boolean* structuralColumn, ElementId* levelId)
at ?A0xa6a4641f.addFamilyInstanceEx(ADocument* pADoc, Owner<FamilyInstance>* oFamilyInstance, Enum structuralType, ElementId* levelId, Boolean* shouldRegen, Boolean batchprocessing)
at Autodesk.Revit.Creation.addFamilyInstance(ADocument* pADoc, FamilyInstance* pFamilyInstance, Enum structuralType, Boolean* shouldRegen, ElementId* levelId)
at Autodesk.Revit.Creation.ItemFactoryBase.NewFamilyInstance(XYZ location, FamilySymbol symbol, Element host, StructuralType structuralType)

```

The code snippet i’m trying to use :

```python
def processColumn(self, columnDict,level):
        try:
            xCoordinate = float(columnDict["origoPos"]["x"])*1000
            yCoordinate = float(columnDict["origoPos"]["y"])*1000
            zCoordinate = float(columnDict["origoPos"]["z"])*1000
            basePoint=Point.ByCoordinates(xCoordinate,yCoordinate,zCoordinate)       

            symbol=columnDict["symbol"]

            TransactionManager.Instance.EnsureInTransaction(self.doc)
            symbol.Activate()
            fam=self.doc.Create.NewFamilyInstance(basePoint.ToXyz(), symbol, level , StructuralType.Column)
            TransactionManager.Instance.TransactionTaskDone()   
            return fam 
        except Exception as e:
            return e

```

The inputparameters (basePoint, symbol, level,StructuralType.Column) seem to be valid. Does anybody know what the cause of this error could? Currently im using Revit 2023.1 with DYNAMO v.2.16.2 . Weird thing is that the columns do get placed:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/7/1/71f69d510568f5c31e5a9897e22a6450bd3f5af6.png)

But they don’t get assigned to the level:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/5/b56b5123acb6703a3af0b2aba713ba45c6dbbc9e.png)  
The level im inputting is an actual existing level. I hope somebody could help me out here.

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [January 24, 2025, 4:28pm UTC](https://forum.dynamobim.com/t/placing-a-column-with-python-node/107484/2 "2025-01-24T16:28:20Z")

</div>

The error says you haven’t provided a valid reference level. Your code looks correct but we can’t see what you’re actually providing as inputs. Share your full code and a screenshot of any inputs from Dynamo.

---

<div class="post-metadata">

**Author:** ![donny.hoogendorp](https://avatars.discourse-cdn.com/v4/letter/d/9e8a1a/32.png) [@donny.hoogendorp](https://forum.dynamobim.com/u/donny.hoogendorp)\
**Post date:** [January 27, 2025, 7:20am UTC](https://forum.dynamobim.com/t/placing-a-column-with-python-node/107484/3 "2025-01-27T07:20:03Z")

</div>

I’m sorry for the mistake. The way how i get the levels is as follows:

```python
def processColumn(self, columnDict):
        try:
            xCoordinate = float(columnDict["origoPos"]["x"])*1000
            yCoordinate = float(columnDict["origoPos"]["y"])*1000
            zCoordinate = float(columnDict["origoPos"]["z"])*1000
            basePoint=Point.ByCoordinates(xCoordinate,yCoordinate,zCoordinate)       

            symbol=columnDict["symbol"]
            levels= FilteredElementCollector(self.doc).OfCategory(BuiltInCategory.OST_Levels).WhereElementIsNotElementType().ToElements()
  
            TransactionManager.Instance.EnsureInTransaction(self.doc)
            symbol.Activate()
            fam=self.doc.Create.NewFamilyInstance(basePoint.ToXyz(), symbol, levels[0], StructuralType.Column)

            TransactionManager.Instance.TransactionTaskDone()   
            return fam 
        except Exception as e:
            return e

```

Does this help @Nick_Boyts ?

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [January 27, 2025, 1:28pm UTC](https://forum.dynamobim.com/t/placing-a-column-with-python-node/107484/4 "2025-01-27T13:28:55Z")

</div>

Get rid of the try/except loop to see what errors you get. If that doesn’t help, share the DYN and a simplified sample RVT so we can test.

---

<div class="post-metadata">

**Author:** ![donny.hoogendorp](https://avatars.discourse-cdn.com/v4/letter/d/9e8a1a/32.png) [@donny.hoogendorp](https://forum.dynamobim.com/u/donny.hoogendorp)\
**Post date:** [January 27, 2025, 2:36pm UTC](https://forum.dynamobim.com/t/placing-a-column-with-python-node/107484/5 "2025-01-27T14:36:39Z")

</div>

With the try/except-block removed i get the same error. So the script i use now is as below. As Template i use a blank Template from revit 2023.1 (Metric-Architectural Template). I just paste the code below in a python node in a blank .dyn file, this should reproduce the error (see image).

```python

# Load the Python Standard and DesignScript Libraries
import clr
clr.AddReference('RevitAPI')
clr.AddReference("RevitServices")
clr.AddReference('ProtoGeometry')
clr.AddReference("RevitNodes")
clr.AddReference('System')
from Autodesk.Revit.DB import BuiltInCategory
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Plumbing import *
import Autodesk
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
import System
from Autodesk.DesignScript.Geometry import *
from System.Collections.Generic import *
from Autodesk.Revit.DB import FilteredElementCollector, FamilySymbol, Level, Transaction
from Revit.Elements import StructuralType

xCoordinate = 2500
yCoordinate = 0
zCoordinate = 0
doc = DocumentManager.Instance.CurrentDBDocument
basePoint=Point.ByCoordinates(xCoordinate,yCoordinate,zCoordinate) 
symbols = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Columns).WhereElementIsElementType().ToElements()
levels = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Levels).WhereElementIsNotElementType().ToElements()

TransactionManager.Instance.EnsureInTransaction(doc)
symbols[0].Activate()
fam=doc.Create.NewFamilyInstance(basePoint.ToXyz(), symbols[0], levels[0], StructuralType.Column)
TransactionManager.Instance.TransactionTaskDone() 

```

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/1/214a1a59b7deae491c74799ee1f31105d010bc4e.png)

---

<div class="post-metadata">

**Author:** ![Nick\_Boyts](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/nick_boyts/32/76313_2.png) [@Nick\_Boyts](https://forum.dynamobim.com/u/Nick_Boyts)\
**Post date:** [January 27, 2025, 9:30pm UTC](https://forum.dynamobim.com/t/placing-a-column-with-python-node/107484/6 "2025-01-27T21:30:24Z")

</div>

It looks like CPython3 might still have issues with overload methods unfortunately.

This thread has a little more explanation: [Creating column on a point using NewFamilyInstance - Revit - Dynamo](https://forum.dynamobim.com/t/creating-column-on-a-point-using-newfamilyinstance/82225)

---

<div class="post-metadata">

**Author:** ![c.poupin](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/c.poupin/32/89152_2.png) [@c.poupin](https://forum.dynamobim.com/u/c.poupin)\
**Post date:** [February 2, 2025, 12:05pm UTC](https://forum.dynamobim.com/t/placing-a-column-with-python-node/107484/7 "2025-02-02T12:05:40Z")

</div>

Hi @donny.hoogendorp

try to use this method instead

> **[NewFamilyInstance Method (XYZ, FamilySymbol, Element, Level, StructuralType)](https://www.revitapidocs.com/2024/168d4c67-73dd-d7c8-4969-12846eeaddfa.htm)**
>
> Online Documentation for Autodesk's Revit API: 2015, 2016, 2017, 2017.1, 2018

and `StructuralType` must come from the `Autodesk.Revit.DB.Structure` NameSpace

```python
# Load the Python Standard and DesignScript Libraries
import clr
clr.AddReference('RevitAPI')
clr.AddReference("RevitServices")
clr.AddReference('ProtoGeometry')
clr.AddReference("RevitNodes")
clr.AddReference('System')
from Autodesk.Revit.DB import BuiltInCategory
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Plumbing import *
from Autodesk.Revit.DB.Structure import StructuralType
import Autodesk
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
import System
from Autodesk.DesignScript.Geometry import *
from System.Collections.Generic import *
from Autodesk.Revit.DB import FilteredElementCollector, FamilySymbol, Level, Transaction

xCoordinate = 2500
yCoordinate = 0
zCoordinate = 0
doc = DocumentManager.Instance.CurrentDBDocument
basePoint=Point.ByCoordinates(xCoordinate,yCoordinate,zCoordinate) 
symbols = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Columns).WhereElementIsElementType().ToElements()
levels = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Levels).WhereElementIsNotElementType().ToElements()

TransactionManager.Instance.EnsureInTransaction(doc)
symbols[0].Activate()
fam=doc.Create.NewFamilyInstance(basePoint.ToXyz(), symbols[0], levels[0], levels[0], StructuralType.Column)
TransactionManager.Instance.TransactionTaskDone()

```

---

<div class="post-metadata">

**Author:** ![christian.stan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/christian.stan/32/166296_2.png) [@christian.stan](https://forum.dynamobim.com/u/christian.stan)\
**Post date:** [February 2, 2025, 12:18pm UTC](https://forum.dynamobim.com/t/placing-a-column-with-python-node/107484/8 "2025-02-02T12:18:27Z")

</div>

Hi, you set the level argument twice 😉  
edit: I didn’t say anything I saw that it was the host (always think before speaking, sorry)

cordially  
christian.stan

---

<div class="post-metadata">

**Author:** ![c.poupin](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/c.poupin/32/89152_2.png) [@c.poupin](https://forum.dynamobim.com/u/c.poupin)\
**Post date:** [February 2, 2025, 12:26pm UTC](https://forum.dynamobim.com/t/placing-a-column-with-python-node/107484/9 "2025-02-02T12:26:05Z")

</div>

yes 😉

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/4/e4c3e73edbebdabf8bbcf710c137379b195fc315.png)

---

<div class="post-metadata">

**Author:** ![christian.stan](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/christian.stan/32/166296_2.png) [@christian.stan](https://forum.dynamobim.com/u/christian.stan)\
**Post date:** [February 2, 2025, 12:29pm UTC](https://forum.dynamobim.com/t/placing-a-column-with-python-node/107484/10 "2025-02-02T12:29:50Z")

</div>

question in passing: the Activate() method of the familySymbol class must be included in the transaction?  
cordially  
christian.stan

---

<div class="post-metadata">

**Author:** ![c.poupin](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/c.poupin/32/89152_2.png) [@c.poupin](https://forum.dynamobim.com/u/c.poupin)\
**Post date:** [February 2, 2025, 12:32pm UTC](https://forum.dynamobim.com/t/placing-a-column-with-python-node/107484/11 "2025-02-02T12:32:06Z")

</div>

it is not mandatory
