Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Family Instances_RevitPythonShell

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
stathiseleftheriadis
478 Views, 3 Replies

Family Instances_RevitPythonShell

Hi,
 
I'm having troubles placing an instance of a standard family in Revit 2014 using PythonShell. The code is based on this http://wiki.theprovingground.org/revit-api-py-family 
 
Any ideas why it doesn't work.
 
Thanks.
 
Stathis
3 REPLIES 3
Message 2 of 4

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

Message 3 of 4

Thanks Maciej.

 

It works perfectly fine now.

 

Stathis

Message 4 of 4
sanosji
in reply to: maciejwypych

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()

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community