How to get InPlaceFamilies?

Hello,

my code does nothing and it takes a lot of time :frowning:

import clr

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

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *

clr.AddReference('System')
from System.Collections.Generic import List

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

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument


elements = UnwrapElement(IN[0])
Inplaced = []

for i in elements:
	try:
		Inplaced.append(i.IsInPlace)
	except:
		Inplaced.append(False)
		
OUT = Inplaced

KR

Andreas

IsInPlace only works for Families. All Elements in Active View collects FamilyInstances which does not have the property .IsInPlace.

Same Python script as yours:

2 Likes

@leonard.moelders,

i will test it

@leonard.moelders ,

it remains empty :frowning:


in my view there are severial. i got not error

You need to get the Families:
You get no error because of your try-except method

Get the families and it works:

Code:

import clr

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

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *

clr.AddReference('System')
from System.Collections.Generic import List

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

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument


elements = UnwrapElement(IN[0])
Inplaced = []

for i in elements:
	if isinstance(i, FamilyInstance):
		type_id = i.GetTypeId()
		fam_type = doc.GetElement(type_id)
		fam = fam_type.Family
		Inplaced.append(fam.IsInPlace)

		
OUT = Inplaced
1 Like

@leonard.moelders ,

hmmm… i still get it

If you are still using your old code you need to have an input like this:

image

Family not Family Type

Maybe I am missing here something but when I look into the API I can only find IsInPlace as a property of the Family Class and not Family Type neither Family Instance.

1 Like

@leonard.moelders ,

i removed list.clean

than it works!


thanks!