Error With API Method NewFamilyInstance

Hi all!

I am trying to create beams at the location of walls getting the wall location for the lines.

Trying to use the NewFamilyInstance with the lines, familySymbol (I tried extracting symbol from beam in project as well as inputing familytype), level, and structural framing type - I am getting the following error:
no method matches arguments for NewFamilyInstance: autodesk.revit.db.line, autodesk.revit.db.familysymbol, autodesk.revit.db.level, revit.elements.familytype.

Is there a way around this?

Using the BeamsByCurve node the beams do work, though I would like to solve it through the custom api script.

import clr
import sys


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

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager 
from RevitServices.Transactions import TransactionManager 

clr.AddReference('RevitAPI')
clr.AddReference('RevitAPIUI')

import Autodesk 
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import *

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


dynCurves = IN[0] if isinstance(IN[0],list) else [IN[0]]
famSymb = UnwrapElement(IN[1])
level = UnwrapElement(IN[2])[0]
structType = IN[3]

revBeams = []
dynBeams = []



#Begin transaction
try:
    TransactionManager.Instance.EnsureInTransaction(doc)
    for curv in dynCurves:
        revCurv = curv.ToRevitType()
        
        if not famSymb.IsActive:
            famSymb.Activate()
        newFam = doc.Create.NewFamilyInstance(revCurv,famSymb, level, structType)
        revBeams.append(newFam)
        dynBeams.append(newFam.ToProtoType())

#End transaction
finally:
    TransactionManager.Instance.TransactionTaskDone


OUT = dynBeams,revBeams

Hi @zviLNBRQ ,

Welcome to the community.

newFam = doc.Create.NewFamilyInstance(revCurv,famSymb, level, structType)

This is where you are missing on the inputs, here instead of this just replace it with the line below:

newFam = doc.Create.NewFamilyInstance(revCurv,famSymb, level, StructuralType.Beam )

As NewFamilyInstance Method (Curve, FamilySymbol, Level, StructuralType) this is the method you are using and here it’s asking for StructuralType and that is an enumeration not the FamilyType.

Happy Coding,
BM

1 Like

Thank you and thanks for the reply.
Is it it expecting StructuralType.Beam as a string?

Just Make sure to import Autodesk.Revit.DB.Structure Namespace as above coz the particular enumeration is coming from Structure Namespace so it won’t be a string.

1 Like