title: Revit API & Dynamo, Creating a Family Parameter from Project Document
body: <p>I'm trying to create a new family parameter by calling a family's document in a project document and using the FamilyManager method to edit the family. There have been about 10 people asking for this on the Dynamo forums, so I figured I'd give it a shot. Here's my Python script below:</p>
  
  <pre><code>import clr
  clr.AddReference('ProtoGeometry')
  from Autodesk.DesignScript.Geometry import *
  
  clr.AddReference("RevitServices")
  from RevitServices.Persistence import DocumentManager
  from RevitServices.Transactions import TransactionManager
  
  clr.AddReference("RevitAPI")
  from Autodesk.Revit.DB import *
  #The inputs to this node will be stored as a list in the IN variables.
  
  familyInput = UnwrapElement(IN[0])
  
  familySymbol = familyInput.Symbol.Family
  doc = familySymbol.Document
  
  par_name = IN[1]
  par_type = ParameterType.Text
  par_grp = BuiltInParameterGroup.PG_DATA
  
  
  TransactionManager.Instance.EnsureInTransaction(doc)
  
  familyDoc = doc.EditFamily(familySymbol)
  OUT = familyDoc.FamilyManager.AddParameter(par_name,par_grp,par_type,False)
  
  TransactionManager.Instance.TransactionTaskDone()
  </code></pre>
  
  <p>When I run the script, I get this error: </p>
  
  <pre><code>Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed. 
  Traceback (most recent call last):
    File "&lt;string&gt;", line 26, in &lt;module&gt;
  Exception: The document is currently modifiable! Close the transaction before calling EditFamily.
  </code></pre>
  
  <p>I'm assuming that this error is because I am opening a family document that already exists through the script and then never sending the information back to the project document? Or something similar to that. Any tips on how to get around this?</p>