Solved! Go to Solution.
Solved by maciejwypych. Go to Solution.
Hi,
1.It works only in mass environment.
2.The BoxFamily needs to be a mass family (if your family have a different name, you need to replace this value in the code.
3.If you are using Revit 2014 or 2015 you'll need to replace the get_Element method with GetElement.
Thanks,
Maciej
Hi,
I am using Revit 2015 student version. I created a new conceptual mass family template. For the following code, I am not getting any output. Appreciate your assistance.
# IronPython Pad. Write code snippets here and F5 to run.
import clr
clr.AddReference('RevitAPI')
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.DB import *
app = __revit__.Application
doc = __revit__.ActiveUIDocument.Document
t = Transaction(doc, 'Create multiple family instances.')
t.Start()
symbName = 'BoxFamily'
collector = FilteredElementCollector(doc)
collector.OfCategory(BuiltInCategory.OST_Mass)
collector.OfClass(FamilySymbol)
famtypeitr = collector.GetElementIdIterator()
famtypeitr.Reset()
for item in famtypeitr:
famtypeID = item
famsymb = doc.GetElement(famtypeID)
if famsymb.Family.Name == symbName:
#Use nested for loop to create grid of family instances.
for i in range(0,10😞
for j in range(0,10😞
loc = XYZ((i*70),(j*70),0)
familyInst = doc.FamilyCreate.NewFamilyInstance(loc, famsymb, Structure.StructuralType.NonStructural)
t.Commit()
__window__.Close()
But I am getting the output for the following code
import math
import clr
clr.AddReference('RevitAPI')
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.DB import *
doc = __revit__.ActiveUIDocument.Document
t = Transaction(doc,'undo')
#start the transaction (get into the undo stack)
t.Start()
#Create ReferenceArrayArrays
refarar = ReferenceArrayArray()
#Do some math to place points
z = 0
detail = 10
while (z <= detail):
x = 0
refptsarr = ReferencePointArray()
while (x <= detail):
x = x
y = (math.sin(x/3)*10) * (math.sin(z*.4))
z = z
#Create Points that are appended to an array
refptsarr.Append(doc.FamilyCreate.NewReferencePoint(XYZ(x,y,z)))
#Increment x
x= x+(math.pi/detail)
#Increment z
z = z + 1
#create curves
crv = doc.FamilyCreate.NewCurveByPoints(refptsarr)
#create reference arrays
refar = ReferenceArray()
#Append curve refences to the reference arrays
refar.Append(crv.GeometryCurve.Reference)
#Append ReferenceArrays to ReferenceArrayArrays
refarar.Append(refar)
#Get the number of curves stored in the ReferenceArAr.
#Comment this out if you get a failure, inspect the curves and see if a loft is possible
doc.FamilyCreate.NewLoftForm(True, refarar)
#Finish the transaction
t.Commit()
__window__.Close()