New to Python: "Exception: The symbol is not active" error

Hello.
I am new to Python.
I am trying to follow Jeremy Graham’s tutorial.
I am trying to do the exercise where he places instances of a Revit family directly from the API.
My code is identical to his but for some reason I get this error: “Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 25, in
Exception: The symbol is not active.
Parameter name: symbol”

Please see attached the Python script.
Note that I am using Revit 2019. Could it be am issue with the new version?

image

Thanks in advance,

Tom.

1 Like

Hi @Figleggedtom

Error says that your family symbol is not active in the current document. You can solve this by 2 methods. Here is the process in action:

and the script here:

import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *


import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)


import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from Autodesk.Revit.DB.Structure import *

doc = DocumentManager.Instance.CurrentDBDocument
famtype = UnwrapElement(IN[0])

elementlist = list()

TransactionManager.Instance.EnsureInTransaction(doc)

# To Make sure the familysymbol is active

if famtype.IsActive == False:
famtype.Activate()
doc.Regenerate()

for i in range(0,100,10):
newobj = doc.Create.NewFamilyInstance(XYZ(i,0,0),famtype,StructuralType.NonStructural)
elementlist.append(newobj)
TransactionManager.Instance.TransactionTaskDone()
OUT = elementlist

Cheers!

8 Likes

Beautiful! Thanks alot @Kulkul !!

Please mark the post as solved. You’re welcome!

Thank you for posting this.
I was also going through the tutorial and it was not working either.

@Kulkul’s script, however, did not work for me as is. It works, though, if I only add the the snippet of code that activates the familytype. For some reason I cannot understand my Python node was disliking the new loaded modules.

my full script below.

# Enable Python support and load DesignScript library
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

#Import Revit API
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

#Import Manager Classes
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

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


# Place your code below this line

#Assign Document
doc = DocumentManager.Instance.CurrentDBDocument

#Start Transaction
TransactionManager.Instance.EnsureInTransaction(doc)

if familytype.IsActive == False:
	familytype.Activate()
	doc.Regenerate()

for x in range(0,100,10):
	fam = doc.Create.NewFamilyInstance(XYZ(x, 0, 0), familytype, Structure.StructuralType.NonStructural)
	output.append(fam)

#End Transaction
TransactionManager.Instance.TransactionTaskDone()

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