Method to place family by point?

I’m trying to modify a python script which will batch load and place a family into a series of families.

What is the python method to “place family by point?”

Here is what I have so far: (line 46 is where I need help)

import clr
clr.AddReference('RevitAPI')
clr.AddReference('RevitServices')

from Autodesk.Revit.DB import Document, FamilySource, IFamilyLoadOptions
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

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

# The inputs to this node will be stored as a list in the IN variables.
paths = IN[0] 
docpaths = IN[1]

# wrap input inside a list (if not a list) 
if not isinstance(paths, list): 
	paths = [paths] 
if not isinstance(docpaths, list): 
	docpaths = [docpaths]

# ensure loaded families can overwrite existing familiies
class FamilyOption(IFamilyLoadOptions): 
	def OnFamilyFound(self, familylnUse, overwriteParameterValues): 
		overwriteParameterValues = True 

	def OnSharedFamilyFound(self, sharedFamily, familyInUse, source, 
	overwriteParameterValues): 
		source = FamilySource.Family 
		overwriteParameterValues = True 
		return True

# core processing
documents = [] 
families = [] 
for docpath in docpaths: 
	doc=app.OpenDocumentFile(docpath) 
	documents.append(doc) 
for path in paths: 
	family_doc = app.OpenDocumentFile(path) 
	families.append(family_doc) 
	
for document in documents: 
	map(lambda family: family.LoadFamily(document, FamilyOption()), families)
	
	# HELP HERE - I have no idea what this line should be
	map(lambda family: family.PlaceFamily())
	
map(lambda family: family.Close(False), families)
map(lambda document: document.Close(True), documents)

# Assign your output to the OUT variable.
OUT = [paths, docpaths]

I’m sure this is a simple answer for those who already know but I searched the revit api docs and didn’t see any obvious way to do what I want. Is it somewhere in the FamilyInstanceCreationData Constructor?

I am not sure about placing a family within a family but would the normal route of NewFamilyInstance from the Creation docs work? You are also missing the variable of the mapping for map(lambda family: family.PlaceFamily())

Maybe @erfajo has some time and can help?

1 Like

I would say that load one or more family(ies) into another family is doable, and then place the family afterwards when loaded. And there is nodes for this in advance, so no need for coding something by your self…

If you pointed me towards a “Place family in Document” node I could probably figure out the rest. In all my searching I couldn’t find a node like that.

Hi @Bren

If you didn’t already know, Orchid isn’t downloaded from package manage but from here with it’s own installer…

Hope that helps,

Mark

I must be missing something because I can’t find a node (even in Orchid) that performs the "Place family at X,Y,Z in Document” function.

What should I be searching for?

First issue is that you load the families, this can be done with my node. The next thing, is to place something according to coordinates, this looks like an instance thing.
I would presume you could build a graph using some of these nodes. You need only one of my load family node, but which one depends on how you do it. The node to the right is an OOTB node for placing an instance by coordinate.
Capture

3 Likes

I’m still struggling to understand how to place a family in a background document. I think I’m getting errors because the “FamilyInstance.ByCoordinates” node is trying to place the family into the current document instead of the background document.

Is there a way to use this node to place a family in a background document? Or maybe there is a way to open each family, place a family, close it, and open the next?

fam-load-nodes.dyn (33.1 KB)

I think you are right… i would also believe that it is setting the family inn the foreground open document. Looks like a new node for “FamilyInstance.ByCoordinates” is needed to do it in the background open document.

1 Like