# Place Family Instance through the API

**URL:** <https://forum.dynamobim.com/t/place-family-instance-through-the-api/85998>\
**Category:** Developers\
**Tags:** revit, python, dynamo, api\
**Created:** [February 10, 2023, 9:54am UTC](https://forum.dynamobim.com/t/place-family-instance-through-the-api/85998 "2023-02-10T09:54:26Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![danail.momchilov](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/danail.momchilov/32/152056_2.png) [@danail.momchilov](https://forum.dynamobim.com/u/danail.momchilov)\
**Post date:** [February 10, 2023, 9:54am UTC](https://forum.dynamobim.com/t/place-family-instance-through-the-api/85998/1 "2023-02-10T09:54:26Z")

</div>

Hi, everyone!

I am trying to place family instances on a face, using the NewFamilyInstance Method (Reference, XYZ, XYZ, FamilySymbol) method.

Here’s the code:

```auto
familySymbol = UnwrapElement(IN[2])
refVector = XYZ(1, 0, 0)

for i, plFace in enumerate(IN[0]):
	#faceIfb = ItemFactoryBase(plFace)
	for surface in UnwrapElement(IN[1][i]):
		pt = UnwrapElement(IN[3][i])
		ItemFactoryBase.NewFamilyInstance(plFace, pt, refVector, familySymbol)
		#ItemFactoryBase.NewFamilyInstance(faceIfb, pt, refVector, familySymbol)

```

and I get the following error:

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

however, if I try to get an ItemFactoryBase object from the PlanarFace, here’s what happens:

```auto
familySymbol = UnwrapElement(IN[2])
refVector = XYZ(1, 0, 0)

for i, plFace in enumerate(IN[0]):
	faceIfb = ItemFactoryBase(plFace)
	for surface in UnwrapElement(IN[1][i]):
		pt = UnwrapElement(IN[3][i])
		#ItemFactoryBase.NewFamilyInstance(plFace, pt, refVector, familySymbol)
		ItemFactoryBase.NewFamilyInstance(faceIfb, pt, refVector, familySymbol)

```

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

It says it has no public constructor 💁‍♂️  
is it then possible to do that through the API?

edit: forgot to mention what my inputs are

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/9/5955304b5a56a951af77ce35c30ab04f88b55693.jpeg)

so they are PlanarFaces I already got through the API and didn’t wrap , the family type and centerpoints of surfaces for the location

Cheers

---

<div class="post-metadata">

**Author:** ![Draxl\_Andreas](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/draxl_andreas/32/145744_2.png) [@Draxl\_Andreas](https://forum.dynamobim.com/u/Draxl_Andreas)\
**Post date:** [February 10, 2023, 10:04am UTC](https://forum.dynamobim.com/t/place-family-instance-through-the-api/85998/2 "2023-02-10T10:04:20Z")

</div>

@danail.momchilov ,

for placing them you will also need Transactions

> [@How to make a bulk-task to 1 by 1 task in dynamo by Transaktion?](https://forum.dynamobim.com/t/how-to-make-a-bulk-task-to-1-by-1-task-in-dynamo-by-transaktion/83215):
>
> Hello Dynos, i do very simple excercise put a string to comments. The task works well, but i want, that each filling is a task(strg+z)… import clr clr.AddReference('RevitAPI') from Autodesk.Revit.DB import \* from System.Collections.Generic import \* clr.AddReference("RevitServices") import RevitServices from RevitServices.Persistence import DocumentManager from RevitServices.Transactions import TransactionManager doc = DocumentManager.Instance.CurrentDBDocument app = DocumentManager.Instance.C…

KR

Andreas

---

<div class="post-metadata">

**Author:** ![danail.momchilov](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/danail.momchilov/32/152056_2.png) [@danail.momchilov](https://forum.dynamobim.com/u/danail.momchilov)\
**Post date:** [February 10, 2023, 10:04am UTC](https://forum.dynamobim.com/t/place-family-instance-through-the-api/85998/3 "2023-02-10T10:04:44Z")

</div>

OMG ofcourse I do… !

I don’t think it would solve it anyway, as I would’ve gotten a warning about that. But let me give it a try 🙂

---

<div class="post-metadata">

**Author:** ![danail.momchilov](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/danail.momchilov/32/152056_2.png) [@danail.momchilov](https://forum.dynamobim.com/u/danail.momchilov)\
**Post date:** [February 10, 2023, 10:09am UTC](https://forum.dynamobim.com/t/place-family-instance-through-the-api/85998/4 "2023-02-10T10:09:09Z")

</div>

nope, it’s the same:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/2/b225d3d46cd394295f1655ff5780f938c8afac31.jpeg)

---

<div class="post-metadata">

**Author:** ![Draxl\_Andreas](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/draxl_andreas/32/145744_2.png) [@Draxl\_Andreas](https://forum.dynamobim.com/u/Draxl_Andreas)\
**Post date:** [February 10, 2023, 10:36am UTC](https://forum.dynamobim.com/t/place-family-instance-through-the-api/85998/5 "2023-02-10T10:36:35Z")

</div>

@danail.momchilov ,

what your input?

```auto
import clr

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

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *

clr.AddReference('System')
from System.Collections.Generic import List

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
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

#Preparing input from dynamo to revit
familySymbol = UnwrapElement(IN[0])
refVector = XYZ(1,0,0)

TransactionManager.Instance.EnsureInTransaction(doc)
#Do some action in a Transaction
for i, plFace in enumurate(IN[0]):
	for s in UnwrapElement(IN[0][i]):
		pt = UnwrapElement(IN[3][i])
		ItemFactoryBase.NewFamiliyInstance(pFace, pt, revVector, familySymbol)
		
TransactionManager.Instance.TransactionTaskDone()

OUT = "Placed FamilyInstance"

```

it looks you have too many

---

<div class="post-metadata">

**Author:** ![danail.momchilov](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/danail.momchilov/32/152056_2.png) [@danail.momchilov](https://forum.dynamobim.com/u/danail.momchilov)\
**Post date:** [February 10, 2023, 11:03am UTC](https://forum.dynamobim.com/t/place-family-instance-through-the-api/85998/6 "2023-02-10T11:03:58Z")

</div>

Thx, Andreas, sure the points list is enough, but that doesn’t solve the issue:

```auto
t.Start()

for i, plFace in enumerate(IN[0]):
	for pt in UnwrapElement(IN[2][i]):
		ItemFactoryBase.NewFamilyInstance(plFace, pt, refVector, familySymbol)
		
t.Commit()

```

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/d/adba52739f60e31d6e5fdff93066def21291afb9.jpeg)

---

<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 10, 2023, 12:07pm UTC](https://forum.dynamobim.com/t/place-family-instance-through-the-api/85998/7 "2023-02-10T12:07:02Z")

</div>

Hi,  
according to the API doc `ItemFactoryBase.NewFamilyInstance()` is not a Static method

> **[NewFamilyInstance Method (Reference, Line, FamilySymbol)](https://www.revitapidocs.com/2015/4545a04f-b5e8-1921-5a4c-d734bc4874ca.htm)**
>
> Online Documentation for Autodesk's Revit API: 2015, 2016, 2017, 2017.1, 2018

you need an **Revit Document instance** to use it with `doc.Create`

see the example in API Doc

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/0/0/008353128357f54373c75e5577e4119bee4edf8d.png)

related topic

> **[How to use Autodesk.Revit.Creation namespace? (Space creation problem)](https://forums.autodesk.com/t5/revit-api-forum/how-to-use-autodesk-revit-creation-namespace-space-creation/td-p/5722899)**
>
> Hi I am creating a space using the Document.NewSpace(Level,UV) method in the Autodesk.Revit.Creation namespace.   I am strugging with this because it is not the usual format of implementation i am used to since every program i have written...

---

<div class="post-metadata">

**Author:** ![danail.momchilov](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/danail.momchilov/32/152056_2.png) [@danail.momchilov](https://forum.dynamobim.com/u/danail.momchilov)\
**Post date:** [February 10, 2023, 12:27pm UTC](https://forum.dynamobim.com/t/place-family-instance-through-the-api/85998/8 "2023-02-10T12:27:35Z")

</div>

Thank you so much! I’m not sure I am doing the right thing, but I tried to follow these instructions:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/8/588bdefdade064d0ee58b7b6dc9af99d1fd64fb5.jpeg)

Prior to that I am getting the faces as a reference with Options.ComputeReference = True

I might have progressed a bit 😃 …but it now seems that the code thinks I am trying to use a method, taking an XYZ as a first argument, while I’m trying to use the reference one:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/a/5ad17a2d12c6d958c4f7b42e568a747fb6994313.png)

is there something else I am doing wrong?

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [February 10, 2023, 1:31pm UTC](https://forum.dynamobim.com/t/place-family-instance-through-the-api/85998/9 "2023-02-10T13:31:04Z")

</div>

You need to convert your Dynamo points to Revit XYZs.

---

<div class="post-metadata">

**Author:** ![danail.momchilov](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/danail.momchilov/32/152056_2.png) [@danail.momchilov](https://forum.dynamobim.com/u/danail.momchilov)\
**Post date:** [February 10, 2023, 2:07pm UTC](https://forum.dynamobim.com/t/place-family-instance-through-the-api/85998/10 "2023-02-10T14:07:31Z")

</div>

I think that actually worked! just need to tweak it a little bit and convert units for the coordinates

---

<div class="post-metadata">

**Author:** ![Draxl\_Andreas](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/draxl_andreas/32/145744_2.png) [@Draxl\_Andreas](https://forum.dynamobim.com/u/Draxl_Andreas)\
**Post date:** [February 10, 2023, 2:13pm UTC](https://forum.dynamobim.com/t/place-family-instance-through-the-api/85998/11 "2023-02-10T14:13:52Z")

</div>

@danail.momchilov ,

😉

> [@Snooping and calling of BuildInParameters?](https://forum.dynamobim.com/t/snooping-and-calling-of-buildinparameters/76723/2):
>
> BuiltInParameter is WALL\_BASE\_OFFSET and WALL\_TOP\_OFFSET I believe. Also when you snoop, you can go into Parameter Set like you show, then there is a button I believe on the bottom left that says Enums something. This will give you the BIP associated.

---

<div class="post-metadata">

**Author:** ![danail.momchilov](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/danail.momchilov/32/152056_2.png) [@danail.momchilov](https://forum.dynamobim.com/u/danail.momchilov)\
**Post date:** [February 10, 2023, 2:19pm UTC](https://forum.dynamobim.com/t/place-family-instance-through-the-api/85998/12 "2023-02-10T14:19:39Z")

</div>

thx, I was just sharing my thoughts 🙂 I am usually just multiplying or dividing by 30.48

---

<div class="post-metadata">

**Author:** ![danail.momchilov](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/danail.momchilov/32/152056_2.png) [@danail.momchilov](https://forum.dynamobim.com/u/danail.momchilov)\
**Post date:** [February 10, 2023, 2:35pm UTC](https://forum.dynamobim.com/t/place-family-instance-through-the-api/85998/13 "2023-02-10T14:35:59Z")

</div>

Here’s the final code:

```auto
import clr
import sys
sys.path.append('C:\Program Files (x86)\IronPython 2.7\Lib')

import System
from System import Array

clr.AddReference("RevitNodes")

import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference("RevitServices")

import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

clr.AddReference("RevitAPI")
clr.AddReference("RevitAPIUI")

import Autodesk
from Autodesk.Revit.DB import XYZ, Point, FamilySymbol
from Autodesk.Revit.Creation import Document

def cm(a):
	return a/30.48

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
uidoc = uiapp.ActiveUIDocument

familySymbol = UnwrapElement(IN[1])
refVector = XYZ(1, 0, 0)
outlist = []

TransactionManager.Instance.EnsureInTransaction(doc)

for i, plFace in enumerate(IN[0]):
	for pt in UnwrapElement(IN[2][i]):
		ptXYZ = XYZ(cm(pt.X), cm(pt.Y), cm(pt.Z))
		instance = uidoc.Document.Create.NewFamilyInstance(plFace, ptXYZ, refVector, familySymbol)
		outlist.append(instance)
		
TransactionManager.Instance.TransactionTaskDone()

OUT = outlist

```

thank you all for the support, I am actually not sure who to thank first as I had pretty much everything messed up 😃 it’s just the first time I was interacting with the Creation namespace

---

<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 10, 2023, 4:16pm UTC](https://forum.dynamobim.com/t/place-family-instance-through-the-api/85998/14 "2023-02-10T16:16:22Z")

</div>

> [@danail.momchilov](#):
>
> `ptXYZ = XYZ(cm(pt.X), cm(pt.Y), cm(pt.Z))`

you can use the `ToXyz()` extension method (conversion)  
see here

> **[Python 0.6.3 to 0.7.x Migration](https://github.com/DynamoDS/Dynamo/wiki/Python-0.6.3-to-0.7.x-Migration#geometryobjects)**
>
> Open Source Graphical Programming for Design. Contribute to DynamoDS/Dynamo development by creating an account on GitHub.
