Get family type as Dynamo object

I have customised a clockwork node so that I can get all of the family types from within a queried family document from file path.

I can get its name (as that seems to be one of the only available properties on API docs of the family type class) but when outputting it I am having trouble trying to get the actual ‘Family Type’ back into a Dynamo compatible object.

Instead I am stuck with the Revit API object ‘Autodesk.Revit.DB.FamilyType’

Since this object has no Id property and I failed in trying to use the .ToDSType() command, how would it be possible to get the revit entity as a dynamo entity?

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

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager

#doc = DocumentManager.Instance.CurrentDBDocument
doc = IN[0]
elementlist = list()
nameslist = list()
if doc.IsFamilyDocument:
	for ftype in doc.FamilyManager.Types:
		elementlist.append(ftype)
		nameslist.append(ftype.Name)
OUT = [elementlist,nameslist]

Any help appreciated!
J

Bumping - Any Dynamo/Python experts got a spare min?

@haganjake2 I think it is not possible to get the family types within a family document since the family needs to be “placed” within a project document so the types can “exist”, even the Family.All node from the Orchid package will output families within a family document, and not the family types created within the family document, maybe I am wrong…That being said, you can try a workaround to load families to a blank project and then extract the family types by family, hope it is what you are after:

I think you maybe have mis-interpreted the question since I have already got the family types from within the family document as seen here:

Using these lines of code:

for ftype in doc.FamilyManager.Types:
		elementlist.append(ftype)

It’s turning them back into Family Type objects that Dynamo can read that I’m struggling with

I think you are on the right track - maybe you can use

1 Like

In my experience types of actual families in the family editor environment aren’t able to be wrapped back (I think, pretty sure I tried that). Usually when working with family types I use custom nodes to work with that object in its DB state, and it should be fine to pass into other nodes. Family types in family documents are quite unique in how they work, another good example of this is the forwarditerator for getting family types which is quite different from iterating with other objects in Dynamo/Revit.

1 Like

DB.FamilyType does not inherit from DB.Element class therefore the Revit.Elements.ElementWrapper (which seems to require DB.Element only) can’t work

2 Likes

Yes they do seem pretty bespoke! Wondering if it was even worth the time coming down this rabbit hole haha.

Ah well, the more you know. Thanks for the comment, what custom nodes would you recommend for working within family environment that ARENT Orchid ?

Cheers,
Jake

Cheers Cyril, thats good to know.

Definitely could do with working out the nuances of API docs so that I spot these things also!

Hrm there aren’t many out there I’ve come across aside from Orchid. I built a handful into Crumple in Python as I couldn’t get consistent outcomes from Orchid over time (list levels and condense options seemed to change between builds, unsure).

1 Like

Cheers, Gavin,

I’ve got Crumple so will have a gander at what you’ve done to see if I can glean anything from your code!

Cheers

1 Like