# Place workplane based family (error code 5)

**URL:** <https://forum.dynamobim.com/t/place-workplane-based-family-error-code-5/81787>\
**Category:** Revit\
**Tags:** revit, python, dynamo\
**Created:** [October 5, 2022, 3:02pm UTC](https://forum.dynamobim.com/t/place-workplane-based-family-error-code-5/81787 "2022-10-05T15:02:00Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![jnoordzij](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jnoordzij/32/32419_2.png) [@jnoordzij](https://forum.dynamobim.com/u/jnoordzij)\
**Post date:** [October 5, 2022, 3:02pm UTC](https://forum.dynamobim.com/t/place-workplane-based-family-error-code-5/81787/1 "2022-10-05T15:02:00Z")

</div>

What is a good way to place a workplane based family, for example onto a reference plance? I can find only nodes that require a face as the host.

Place by face would mean that I first have to create a Revit element, just for its geometry, then retreive the correct face, then place the instances and then remove the host element. Not cool.

I have found [this](https://forum.dynamobim.com/t/place-family-workplane-problem/18811/2) topic which shows some API code to place an instane based on a reference plane, but the code is not designed to handle lists.

I have tried to tackle that by modifying the code, as you can see underneath, but I get an error I cant understand. Can you please give some advice?

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

```auto
import clr
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
from Revit.Elements import *
clr.AddReference('System')
from System.Collections.Generic import *
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

def BuildInstance(symbol, refPlane, location, referenceDirection, doc):
	symbol.Activate()
	reference = Reference(refPlane)
	new = doc.Create.NewFamilyInstance(reference,location.ToXyz(),referenceDirection.ToXyz(),symbol)
	return new

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

#The inputs to this node will be stored as a list in the IN variables.
symbol = UnwrapElement(IN[0])
refPlanes = UnwrapElement(IN[1])
pointgroups = UnwrapElement(IN[2])
referenceDirections = UnwrapElement(IN[3])
out = []

TransactionManager.Instance.EnsureInTransaction(doc)

for group in pointgroups:
	i = pointgroups.IndexOf(group)
	for point in group:
		new = BuildInstance(symbol, refPlanes[i], point, referenceDirections[i], doc)
		out.append(new)

TransactionManager.Instance.TransactionTaskDone()

#Assign your output to the OUT variable.
OUT = new

```

---

<div class="post-metadata">

**Author:** ![jnoordzij](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jnoordzij/32/32419_2.png) [@jnoordzij](https://forum.dynamobim.com/u/jnoordzij)\
**Post date:** [October 5, 2022, 3:09pm UTC](https://forum.dynamobim.com/t/place-workplane-based-family-error-code-5/81787/2 "2022-10-05T15:09:19Z")

</div>

Furthermore, I am looking at FamilyInstanceByFace.  
When you feed it a plane instead of a face, it says it needs a Dynamo Surface  
 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/6/a6eb71b6b3d695ac9a791dc99094d06cb6f02f46.png)

If you feed it a dynamo surface, it says it needs an ElementFaceReference

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

If you feed it an ElementFaceReference it says it needs a Surface ☹

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

How is this supposed to work?

---

<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:** [October 5, 2022, 3:13pm UTC](https://forum.dynamobim.com/t/place-workplane-based-family-error-code-5/81787/3 "2022-10-05T15:13:19Z")

</div>

The node needs the face reference of the geometry surface. It’s confusing. I’d ignore the node for now.

Make sure the original python code works for a single instance first. It should, that method has not changed. If it does, then you can move on to handling a list of inputs. I would recommend zipping your lists instead of using an index. I find it easier to follow and troubleshoot. Also, when in doubt, make your input structure as easy as possible. Make sure everything lines up.

---

<div class="post-metadata">

**Author:** ![Alban\_de\_Chasteigner](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alban_de_chasteigner/32/39650_2.png) [@Alban\_de\_Chasteigner](https://forum.dynamobim.com/u/Alban_de_Chasteigner)\
**Post date:** [October 5, 2022, 3:14pm UTC](https://forum.dynamobim.com/t/place-workplane-based-family-error-code-5/81787/4 "2022-10-05T15:14:11Z")

</div>

Hi,

If you want to place instances on a reference plane, the _FamilyInstance ByReference_ node of the Genius Loci package will work.

---

<div class="post-metadata">

**Author:** ![jnoordzij](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jnoordzij/32/32419_2.png) [@jnoordzij](https://forum.dynamobim.com/u/jnoordzij)\
**Post date:** [October 5, 2022, 3:18pm UTC](https://forum.dynamobim.com/t/place-workplane-based-family-error-code-5/81787/5 "2022-10-05T15:18:47Z")

</div>

@Alban_de_Chasteigner I tried your suggestion but im confused. The description says it can handle a reference plane:

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

But the parameter description says it needs a face from an element.

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

I have tried with feeding referenceplane but then an error comes.

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

---

<div class="post-metadata">

**Author:** ![Alban\_de\_Chasteigner](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/alban_de_chasteigner/32/39650_2.png) [@Alban\_de\_Chasteigner](https://forum.dynamobim.com/u/Alban_de_Chasteigner)\
**Post date:** [October 5, 2022, 3:24pm UTC](https://forum.dynamobim.com/t/place-workplane-based-family-error-code-5/81787/6 "2022-10-05T15:24:39Z")

</div>

You need a Autodesk.Revit.DB.Reference in the input reference.  
Use the Element Reference to obtain it from the reference plane.

---

<div class="post-metadata">

**Author:** ![jnoordzij](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jnoordzij/32/32419_2.png) [@jnoordzij](https://forum.dynamobim.com/u/jnoordzij)\
**Post date:** [October 5, 2022, 3:45pm UTC](https://forum.dynamobim.com/t/place-workplane-based-family-error-code-5/81787/8 "2022-10-05T15:45:48Z")

</div>

Thanks for the advice @Alban_de_Chasteigner .

At first I got it to work. As you can see from image below.

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

But then … I messed up again X), and now it doesnt work anymore. And **I get the exact same ‘Error code 5’** with the Genius Loci node as I got with my own code in my post above.

So the question now becomes: does anyone know what **error code 5** is?

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

---

<div class="post-metadata">

**Author:** ![jnoordzij](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jnoordzij/32/32419_2.png) [@jnoordzij](https://forum.dynamobim.com/u/jnoordzij)\
**Post date:** [October 5, 2022, 6:11pm UTC](https://forum.dynamobim.com/t/place-workplane-based-family-error-code-5/81787/9 "2022-10-05T18:11:22Z")

</div>

Here is a reproducable sample (dyn and dummy are attached). What is wrong with this code?

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

[Dummy.rfa](https://forum.dynamobim.com/uploads/short-url/7mES3QTRPtgYLnxVq2YW7NErbVW.rfa) (408 KB)

[error.dyn](https://forum.dynamobim.com/uploads/short-url/eNSXNgOsb5kbFLq1pIGgozAVf4n.dyn) (22.0 KB)

FYI 2 nodes are from the GeniusLoci package:

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

---

<div class="post-metadata">

**Author:** ![jnoordzij](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jnoordzij/32/32419_2.png) [@jnoordzij](https://forum.dynamobim.com/u/jnoordzij)\
**Post date:** [October 5, 2022, 6:37pm UTC](https://forum.dynamobim.com/t/place-workplane-based-family-error-code-5/81787/10 "2022-10-05T18:37:43Z")

</div>

I believe I have it. I am a dumbass and had my vectors mixed up…

---

<div class="post-metadata">

**Author:** ![jnoordzij](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jnoordzij/32/32419_2.png) [@jnoordzij](https://forum.dynamobim.com/u/jnoordzij)\
**Post date:** [October 6, 2022, 5:25am UTC](https://forum.dynamobim.com/t/place-workplane-based-family-error-code-5/81787/11 "2022-10-06T05:25:10Z")

</div>

So, the answers:

-To place a workplane based family use FamilyInstance.ByReference from Genius Loci

-Error code 5: dont know what it means exactly but my mistake was feeding a vector which was not on the workplane as a direction. The direction given should correspond to the family’s internal positive x direction
