# Placing a new family on a face in Python

**URL:** <https://forum.dynamobim.com/t/placing-a-new-family-on-a-face-in-python/13335>\
**Category:** Uncategorized\
**Tags:** python, dynamo\
**Created:** [July 20, 2017, 12:42pm UTC](https://forum.dynamobim.com/t/placing-a-new-family-on-a-face-in-python/13335 "2017-07-20T12:42:31Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![Dharman](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/dharman/32/20649_2.png) [@Dharman](https://forum.dynamobim.com/u/Dharman)\
**Post date:** [January 31, 2018, 7:29am UTC](https://forum.dynamobim.com/t/placing-a-new-family-on-a-face-in-python/13335/8 "2018-01-31T07:29:36Z")

</div>

Hi Kevin,  
There is some working python code in the Springs package: `Springs.FamilyInstance.ByFacePoints` that uses this method. I have pasted it below. Thanks to @Dimitar_Venkov

```
#Copyright(c) 2016, Dimitar Venkov
# @5devene, dimitar.ven@gmail.com

import clr

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

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

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

def tolist(obj1):
	if hasattr(obj1,' __iter__'): return obj1
	else: return [obj1]

def first(obj1):
	if hasattr(obj1,' __iter__'): return obj1[0]
	else: return obj1

host = first(IN[0])
ftype = UnwrapElement(first(IN[1]))
pts = tolist(IN[2])

OUT = []
ref1 = host.Tags.LookupTag("RevitFaceReference")
TransactionManager.Instance.EnsureInTransaction(doc)
for i in xrange(len(pts) ):
	uv1 = host.UVParameterAtPoint(pts[i])
	dir1 = host.TangentAtUParameter(uv1.U,uv1.V).ToXyz()
	try:
		inst1 = doc.Create.NewFamilyInstance(ref1,pts[i].ToXyz(),dir1,ftype)
		OUT.append(inst1.ToDSType(False) )
	except: OUT.append(None)
TransactionManager.Instance.TransactionTaskDone()

```

I have found that if i try to use `NewFamilyInstance(Face, XYZ, XYZ, FamilySymbol)` method in any other way (even the most basic single call) i also get a type error such as `TypeError: expected XYZ, got Reference`

@Dimitar_Venkov could you possibly explain why your call to this method above works, but mine (below) doesn’t? I’ve simplified it as much as possible removing any loops, and making each input a single item. Ideally i want to be able to call `NewFamilyInstance` within a my own class method. Also i’m curious how you found `ref1 = face.Tags.LookupTag("RevitFaceReference")`

```
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
#----------------------------------------------------------INPUTS
familyType = IN[0]
face = IN[1]
origin = IN[2]
direction = IN[3]
#----------------------------------------------------------DEFINITIONS

#----------------------------------------------------------MAIN

ref1 = face.Tags.LookupTag("RevitFaceReference")

TransactionManager.Instance.EnsureInTransaction(doc)
#create instance
e = doc.Create.NewFamilyInstance(ref1, origin.ToXyz(), direction.ToXyz(), familyType)

TransactionManager.Instance.TransactionTaskDone()

#----------------------------------------------------------OUT
OUT = e
```

---

_[View the full topic](https://forum.dynamobim.com/t/placing-a-new-family-on-a-face-in-python/13335)._
