Place family based on location linked nested element

Hi,

In a previous topic i learned how to retrieve the nested elements from family’s inside a linked model.
The next step is to place family’s based on the location, however it returns an error using the Element.Getlocation node.

I welcome any help possible.

@kleinnagelvoort ,

you have to access your list in the correct depth… try flatten, use from Clockwork Element.Location+

It returns an empty list

Are you collecting tags? @kleinnagelvoort

They are listed as generic models

you are just filering the nested families right? @kleinnagelvoort

Yes the elements i filtered are all nested

@kleinnagelvoort ,

i found a old topic:

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

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

element = UnwrapElement(IN[0])

loc = element.Location
if isinstance(loc, LocationPoint):
	rvtPoint = loc.Point
	protoPoint = rvtPt.ToPoint()

OUT = loc

it works for one element. and the point is missing but you have a location

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

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

element = UnwrapElement(IN[0])

loc = element.Location
locs = []

def locorign(x):
	if isinstance(loc, LocationPoint):
		rvtPoint = loc.Point
		protoPoint = rvtPt.ToPoint()
	
for i in element:
	locs.append(locorign(i))
	
OUT = locs, loc


Thats not working, but in this way it can run, maybe it is posible to convert the orgin to a point

Not quiet sure how to move forward from this,i still get an empty list.
Also by gettin only one element its faster to place instances manualy i’d say.

Thank you for the effort but Iam not sure if this is the solution

@kleinnagelvoort most probably you are collecting families, you need to collect the instances of these families in order to get the instances location.

2 Likes

2022-05-25_11h18_04
I get nothing from the nested family @tradelie @kleinnagelvoort

You need to transform the Revit point to a dynamo point :wink:

1 Like

how can i do this magic ? :wink: @jw.vanasselt

have to load “ProtoGeometry” Library to load?
and call anything? or is it converting?

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

You need to use .ToProtoType()

In this case you need to change

in

for i in element:
	locs.append(locorign(i).ToProtoType())
import clr #.NET Laden
import sys #sys is de fundamentele Python bibliotheek
#de standaard IronPython-bibliotheken
#sys.path.append('C:\Program Files (x86)\IronPython 2.7\Lib') #Imports the
#standaard IronPython-bibliotheken, die alles dekken, van servers en
#encryptie tot reguliere expressies.
import System #The System namespace in de hoofdmap .NET
from System import Array #.NET class voor het verwerken van array-informatie
import System.Collections.Generic as MGen #Module kan nu benaderd worden met MGen.xxxx
#from System.Collections.Generic import * #Hiermee kunt u generieke afhandelen. Revit's API
#soms wil hard-getypte 'generieke' lijsten, genaamd ILists. Als je niet nodig hebt
#deze kunt u deze regel verwijderen.
clr.AddReference('ProtoGeometry')  #Een Dynamo-bibliotheek voor zijn proxygeometrie
#classes. Je hebt dit alleen nodig als je interactie hebt met geometrie.
import Autodesk.DesignScript.Geometry as AGeo #Module kan worden opgeroepen a=met AGeo.xxxx
#from Autodesk.DesignScript.Geometry import * #Laadt alles in Dynamo's
#geometriebibliotheek
clr.AddReference("RevitNodes") #Dynamo's nodes voor Revit
import Revit #Laad in de Revit-namespaces in RevitNodes
clr.ImportExtensions(Revit.Elements) #Meer laden van Dynamo's Revit-bibliotheken
clr.ImportExtensions(Revit.GeometryConversion) #Meer laden van Dynamo's
#Revit-bibliotheken. Je hebt dit alleen nodig als je interactie hebt met geometrie.
clr.AddReference("RevitServices") #Dynamo's classes voor het omgaan met Revit-documenten
import RevitServices 
from RevitServices.Persistence import DocumentManager #Een interne Dynamo class
#dat het document bijhoudt waaraan Dynamo momenteel is gekoppeld
from RevitServices.Transactions import TransactionManager #Een Dynamo class voor
#transacties openen en sluiten om de database van het Revit-document te wijzigen

clr.AddReference("RevitAPI") #Verwijzing naar Revit's API DLL's toevoegen
clr.AddReference("RevitAPIUI") #Verwijzing naar Revit's APIUI DLL's toevoegen

import Autodesk #Loads the Autodesk namespace
import Autodesk.Revit.DB as RDB #Loading Revit's API UI classes module kan nu worden aangeroepen met RDB.xxxx
#from Autodesk.Revit.DB import * #Loading Revit's API UI classes
import Autodesk.Revit.UI as RUI # Loading Revit's API UI classes als RUI.xxxx
#from Autodesk.Revit.UI import * #Loading Revit's API UI classes

doc = DocumentManager.Instance.CurrentDBDocument #Dit is het actieve Revit document
uiapp = DocumentManager.Instance.CurrentUIApplication #Een handle instellen voor het actieve Revit UI-document
app = uiapp.Application  #Een handle instellen op de momenteel geopende instantie van de Revit-toepassing
uidoc = uiapp.ActiveUIDocument #Een handle instellen op de momenteel geopende instantie van de Revit UI-toepassing


# einde code omrekenen revit feet naar huidig ingestelde document units
# Hieronder kan je dan gaan programmeren
# Gebruik boiler template

#Start Transaction
#TransactionManager.Instance.EnsureInTransaction(doc)
#Eind Transactie
#TransactionManager.Instance.TransactionTaskDone()

rdb_xyz = RDB.XYZ(0,0,0)
point = RDB.Point.Create(rdb_xyz)

OUT = point.ToProtoType()
2 Likes
import clr #.NET Laden
import sys #sys is de fundamentele Python bibliotheek
#de standaard IronPython-bibliotheken
#sys.path.append('C:\Program Files (x86)\IronPython 2.7\Lib') #Imports the
#standaard IronPython-bibliotheken, die alles dekken, van servers en
#encryptie tot reguliere expressies.
import System #The System namespace in de hoofdmap .NET
from System import Array #.NET class voor het verwerken van array-informatie
import System.Collections.Generic as MGen #Module kan nu benaderd worden met MGen.xxxx
#from System.Collections.Generic import * #Hiermee kunt u generieke afhandelen. Revit's API
#soms wil hard-getypte 'generieke' lijsten, genaamd ILists. Als je niet nodig hebt
#deze kunt u deze regel verwijderen.
clr.AddReference('ProtoGeometry')  #Een Dynamo-bibliotheek voor zijn proxygeometrie
#classes. Je hebt dit alleen nodig als je interactie hebt met geometrie.
import Autodesk.DesignScript.Geometry as AGeo #Module kan worden opgeroepen a=met AGeo.xxxx
#from Autodesk.DesignScript.Geometry import * #Laadt alles in Dynamo's
#geometriebibliotheek
clr.AddReference("RevitNodes") #Dynamo's nodes voor Revit
import Revit #Laad in de Revit-namespaces in RevitNodes
clr.ImportExtensions(Revit.Elements) #Meer laden van Dynamo's Revit-bibliotheken
clr.ImportExtensions(Revit.GeometryConversion) #Meer laden van Dynamo's
#Revit-bibliotheken. Je hebt dit alleen nodig als je interactie hebt met geometrie.
clr.AddReference("RevitServices") #Dynamo's classes voor het omgaan met Revit-documenten
import RevitServices 
from RevitServices.Persistence import DocumentManager #Een interne Dynamo class
#dat het document bijhoudt waaraan Dynamo momenteel is gekoppeld
from RevitServices.Transactions import TransactionManager #Een Dynamo class voor
#transacties openen en sluiten om de database van het Revit-document te wijzigen

clr.AddReference("RevitAPI") #Verwijzing naar Revit's API DLL's toevoegen
clr.AddReference("RevitAPIUI") #Verwijzing naar Revit's APIUI DLL's toevoegen

import Autodesk #Loads the Autodesk namespace
import Autodesk.Revit.DB as RDB #Loading Revit's API UI classes module kan nu worden aangeroepen met RDB.xxxx
#from Autodesk.Revit.DB import * #Loading Revit's API UI classes
import Autodesk.Revit.UI as RUI # Loading Revit's API UI classes als RUI.xxxx
#from Autodesk.Revit.UI import * #Loading Revit's API UI classes

doc = DocumentManager.Instance.CurrentDBDocument #Dit is het actieve Revit document
uiapp = DocumentManager.Instance.CurrentUIApplication #Een handle instellen voor het actieve Revit UI-document
app = uiapp.Application  #Een handle instellen op de momenteel geopende instantie van de Revit-toepassing
uidoc = uiapp.ActiveUIDocument #Een handle instellen op de momenteel import clr

element = UnwrapElement(IN[0])

loc = element.Location
locs = []

def locorign(x):
	if isinstance(loc, LocationPoint):
		rvtPoint = loc.Point
		protoPoint = rvtPt.ToPoint()
	
for i in element:
	locs.append(locorign(i).ToProtoType())
	
OUT = locs

2022-05-25_11h58_48

@jw.vanasselt , can`t find Location ?

element = UnwrapElement(IN[0])

loc = []

for x in element:
	loc.append(x.Location)
	
locs = []

def locorign(x):
	if isinstance(loc,LocationPoint):
		rvtPoint = loc.Point
		protoPoint = rvtPt.ToPoint()
	
for i in element:
	locs.append(locorign(i).ToProtoType())
	
OUT = locs

also does not work.
2022-05-25_12h02_45

That is my pythontemplate see my import as (RDB)

Thank you very much, this solves the issue :grinning:

1 Like

I don’t have the right situation to check, but try to change this:

in

def locorign(x):
	if isinstance(loc,LocationPoint):
		rvtPoint = loc.Point
		protoPoint = rvtPt.ToProtoType()
1 Like

The only issue iam having rn is that the placed family’s are not on the location they are suposed to be.
I tried by point and level & point but i get the same result, they get dropped arround the project base point.