Get host from Linked element

2020-08-10_10h46_27
Hello,

I try to find the host from my linked element (doors). So i can get it from doors which are placed native. They work very well.

I have a code for native elements
and some stuff from the buildingcoder (whats is hart do understand!)

i have bakery and GeniusLoci things but i can`t connect the nodes, there is the gab between elements and linked elements.

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

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

toList = lambda x : x if hasattr(x, '__iter__') else [x]
lstelems = toList(UnwrapElement(IN[0]))

def getHostLink(elem):
hostRvt = elem.Host
hostfaceref = elem.HostFace 
if isinstance(hostRvt, RevitLinkInstance):
	linkdoc = hostRvt.GetLinkDocument()
	hostelem = linkdoc.GetElement(hostfaceref.LinkedElementId)
	return hostelem
else:
	return 	hostRvt

lsthost = []
for elem in lstelems:
host = getHostLink(elem)
lsthost.append(host)

OUT = lsthost

LinkedHost.dyn (11.0 KB)

Hi @Draxl_Andreas,

Are the doors and the walls in the same linked model ?

1 Like

Your code doesn’t support a list input. This means that you’re calling a property on a list, instead of the list items. You have 3 options to solve this.
1 Input only one item
2 use a for loop in the definition to add list support to your code
3 Wrap the script in a customnode and use the level options.
Customnodes wrap scripts in a framework that adds list support in the way of list levels.

Thank you, it is big step forward, there is just small error left…doors and walls in the same LINKEDModel
the last point is missing… for any reason, there is no dimension placed.
There is no warning… …just the value “Null” for the final dimension :confused:



createDimensions_V2.dyn (32.3 KB)

Can you verify that the reference input is a flat list? It seems like you’re inputting it as a list structure. You can try a list flatten node before the reference input and see what kind of values that gives you.

1 Like

oh no! is this a german/english problem! the list shows just Right/Left the list shows Rechts

GetValuesInGerman ? is this possible, how can i trick that?

It says also in english.revit Rechts… hmmm

The reference name shouldn’t matter in this case since you’re not actually doing anything with that. You are receiving the referenceplanes, so that works nicely as it should. The problem is with the inputs for the dimension.byReferences node. I have not used that node before so I’m not sure how it is designed to take inputs. Maybe another community member can shed some light on the inner workings of this node?

That said, is it possible that it requires a list structure where one dimension asks for a maximum of 2 references per list?
Maybe try to transpose the list so you have 3 lists with two references each (one right and one left reference). Then set the the references input to level 2. I’m not sure if this works but hey, it’s worth a shot isn’t it? :sweat_smile:
You don’t need to flatten the list for this!

1 Like

hmmm… so transpose do some sorting but in which context

should i search by index the correct value?

You need to convert the references when they come from a linked document:



Dimension linked door.dyn (27.3 KB)

P.S : Please stop publishing content of custom nodes that you did not personaly create.

2 Likes