Convert Family Type to Family

Hi all

For my script to work I need to write a family type to its family. Right now my script isn’t working because it doesn’t take the new element parameters along in the calculation, and I can’t use the element from the [Element.SetParameterByName]. The problem is visible in the attached image.

Thanks in advance,
Please let me know if any additional information is needed (I’m new to Dynamo).

Knowing what the Python script is expecting as an input would help to understand what you are after, but it seems either the FamilyInstance.ByFamilyType node or the FamilyType.Family node might be what you’re looking for?

1 Like

Hi Awilliams,

Thanks for your answer.
The suggested nodes don’t seem to work, they give a different output

As far as i understand, i need the same output from the Element.SetParameterByName node as is given from the Select Model Element (as shown in the image).

I dont really understand the Python script, and i cant upload the document so i have to post it like this:
The node takes a object from a family linked with a material and calculates it’s area.

import clr
clr.AddReference(‘ProtoGeometry’)
clr.AddReference(‘ProtoGeometry’)
clr.AddReference(“RevitNodes”)
clr.AddReference(“RevitServices”)
clr.AddReference(“RevitAPI”)
import Revit
import System
import RevitServices
import Autodesk
from Revit.Elements import *
from Autodesk.DesignScript.Geometry import *
from Autodesk.Revit.DB import *
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

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

#The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN
elems = UnwrapElement(IN[0])
targetmat = IN[1]
output =

geomopt = app.Create.NewGeometryOptions()
geomopt.ComputeReferences = True
geomopt.DetailLevel = Autodesk.Revit.DB.ViewDetailLevel.Fine

matcol = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Materials).WhereElementIsNotElementType()
targetId = -1
for mat in matcol:
if mat.Name == targetmat:
targetId = mat.Id

#foreach object get geometrysolid, get material name, is name name of target
from Autodesk.Revit.DB import *
from Autodesk import *
for elem in elems:
georaw = elem.get_Geometry(geomopt)
sublist =
for geoobj in georaw:
solids = geoobj.GetInstanceGeometry()
for solid in solids:
facearray = solid.Faces
for face in facearray:
matId = face.MaterialElementId
if matId == targetId:#this is area
area = face.Area
normal = face.ComputeNormal(UV(0.5,0.5))
curves = face.GetEdgesAsCurveLoops()
clist =
for car in curves:
for c in car:
pt1 = c.GetEndPoint(0)
pt2 = c.GetEndPoint(1)
l = DesignScript.Geometry.Line.ByStartPointEndPoint(DesignScript.Geometry.Point.ByCoordinates(pt1.X304.8,pt1.Y304.8,pt1.Z304.8),DesignScript.Geometry.Point.ByCoordinates(pt2.X304.8,pt2.Y304.8,pt2.Z304.8))
clist.append(l)
sublist.append([elem,area*0.09290304 ,normal.ToVector(),clist])
output.append(sublist[:])
del sublist[:]
#transaction
TransactionManager.Instance.EnsureInTransaction(doc)

TransactionManager.Instance.TransactionTaskDone()

#Assign your output to the OUT variable.
OUT = output

The FamilyInstance.ByFamilyType node should work because it is basically the inverse of the FamilyInstance.Type node, only it will give you a list of family instances belonging to that type if your project has more than one of them. You can filter that list by doing something like this:

1 Like

That seems to work!
Only it didn’t solve the problem.

Let me try to explain:
Right now i have to press Run twice to get the right outcome. I assumed this is because the new parameter values woudn’t be brought along in the calculations, and that it would be fixed if i took the element after the Element.SetParameterByName node. But apparently not.

Maybe you know how to solve this?
Thanks for the great help so far!

Can you post a dyn and sample file?

It says: Sorry, new users can not upload attachments.

Put a Transaction.End node after the Element.SetParameterByName node - that should do it :slight_smile:

1 Like

Better yet- if you have the Rhythm package or can download it, there are nodes for getting/setting Type parameters (pictured below) so you can eliminate the portion of your graph that gets the family type from family instance and back; also seems that the ending the transaction is built into these nodes

2 Likes

that seemed to do the job! Thank you for the help :hugs:

I’ll need to look into that Rhythm part, i have used it before but it seemed to do the same as the default SetParameter node. Thanks for the tip though, I’m always looking for optimizing my graphs, and I’ll be sure to look into it!

1 Like