Place workplane based family (error code 5)

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 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

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

Furthermore, I am looking at FamilyInstanceByFace.
When you feed it a plane instead of a face, it says it needs a Dynamo Surface
image

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

image

If you feed it an ElementFaceReference it says it needs a Surface :frowning:

image

How is this supposed to work?

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.

Hi,

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

1 Like

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

image

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

image

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

image

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

1 Like

Thanks for the advice @Alban_de_Chasteigner .

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

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?

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

Dummy.rfa (408 KB)

error.dyn (22.0 KB)

FYI 2 nodes are from the GeniusLoci package:

image

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

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

1 Like