I want to achieve this by using the second overload which is in the red-line box, but when I finish my code I met an error said ‘NewFamilyInstance() takes at least 5 arguments (4 given)’, but the method that I want use exzactly needs 4. I am really confused and upset about this. Could anyone be so kind to help me to find the right way to create beams by method provided by RevitAPI?
the code is as follow:
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference("RevitAPIUI")
from Autodesk.Revit.UI import TaskDialog
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB.Events import *
from Autodesk.Revit.DB import *
from Autodesk.Revit.Creation import *
from Autodesk.Revit.DB.Structure import *
from math 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
import System
#def
DOC = DocumentManager.Instance.CurrentDBDocument
UIAPP = DocumentManager.Instance.CurrentUIApplication
UIDOC = UIAPP.ActiveUIDocument
VER = DOC.Application.VersionName.replace("Autodesk Revit","")
LOC = DOC.Application.Language == Autodesk.Revit.ApplicationServices.LanguageType.Chinese_Simplified
Lines=IN[0]
BeamType=IN[1]
RefLevel=IN[2]
Beams=[]
for l in Lines:
rvl=l.ToRevitType()
beam=Autodesk.Revit.Creation.Document.NewFamilyInstance(rvl, BeamType, RefLevel, Autodesk.Revit.DB.Structure.StructuralType.Beam)
Beams.append(beam)
TransactionManager.Instance.TransactionTaskDone()
OUT=Beams
My guess would be to simply replace the word “Beam” with “Column” in this line:
“beam = doc.Create.NewFamilyInstance(line.GeometryCurve, fsymbol, level, Structure.StructuralType.Beam);”
so that the end looks like this:
#create beam
column = doc.Create.NewFamilyInstance(line.GeometryCurve, fsymbol, level, Structure.StructuralType.Column);
columns.append(column);
#transaction end
TransactionManager.Instance.TransactionTaskDone();
OUT = columns;
I write a script for column too, it’s a bit different with beam creation way because of their family nature …
For instance, Beam can create by your curves(lines) geometry and Column can only be created on the origin point. In this example, I created at the start point of each line.
Anyway, the code is provided below and @Jonathan.Olesen your guess is so close …