<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Saving family after editing with FamilyManager in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/saving-family-after-editing-with-familymanager/m-p/5291803#M75611</link>
    <description>&lt;P&gt;Dear Raunoveb,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much for pointing out the IsEditable predicate. I successfully replaced my exception handler by simply checking that instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regarding your locked families, have you tried ensuring that absolutely no other documents are open, only the one and only family that you are trying to modify?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;</description>
    <pubDate>Tue, 23 Sep 2014 09:34:11 GMT</pubDate>
    <dc:creator>jeremytammik</dc:creator>
    <dc:date>2014-09-23T09:34:11Z</dc:date>
    <item>
      <title>Saving family after editing with FamilyManager</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/saving-family-after-editing-with-familymanager/m-p/5291581#M75608</link>
      <description>&lt;P&gt;Hello!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We are developing a solution that uploads Revit Family files to DMS server. First we added a few shared parameters that have the information of DMS record to our families.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;if (doc.IsFamilyDocument)
{
    Family f = doc.OwnerFamily;
    FamilyManager manager = doc.FamilyManager;&lt;BR /&gt;    //Check if parameters have already been added to Family and it's Symbols.&lt;BR /&gt;    //If not then adding parameters using Transaction.
    if (manager.get_Parameter("DMS_DOCNUMBER") == null)
    {
        using (Transaction trans = new Transaction(doc, "PARAM_SET"))
        {
            trans.Start();
            manager.AddParameter("DMS_DOCNUMBER", BuiltInParameterGroup.PG_IDENTITY_DATA, ParameterType.Text, true);
            manager.AddParameter("DMS_DOCVERSION", BuiltInParameterGroup.PG_IDENTITY_DATA, ParameterType.Text, true);
            manager.AddParameter("DMS_DOCTYPE", BuiltInParameterGroup.PG_IDENTITY_DATA, ParameterType.Text, true);
            manager.AddParameter("DMS_DOCPART", BuiltInParameterGroup.PG_IDENTITY_DATA, ParameterType.Text, true);
            trans.Commit();
        }
    }&lt;BR /&gt;    //Create FamilyParameter reference objects after parameters have been added or checked if added  
    FamilyParameter docnr = manager.get_Parameter("DMS_DOCNUMBER");
    FamilyParameter docvers = manager.get_Parameter("DMS_DOCVERSION");
    FamilyParameter doctype = manager.get_Parameter("DMS_DOCTYPE");
    FamilyParameter docpart = manager.get_Parameter("DMS_DOCPART");&lt;BR /&gt;&lt;BR /&gt;    //Setting parameter values for every Symbol in the family
    foreach (FamilyType ft in manager.Types)
    {
        if (!MaterialHasDocument(ft, manager))
        {
            DocumentObj docObj = CreateDMSDocument("RVT");
            using (Transaction trans = new Transaction(doc, "SET_PARAM"))
            {
                trans.Start();
                manager.CurrentType = ft;
                manager.Set(docnr, docObj.docNumber);
                manager.Set(docvers, docObj.docVersion);
                manager.Set(doctype, docObj.docType);
                manager.Set(docpart, docObj.docPart);
                trans.Commit();
            }&lt;BR /&gt;            //This is where we upload the .rfa file&lt;BR /&gt;            //MANY MANY ERRORS
            UploadOriginal(docObj, f, doc);
        }
    }
}
else
{
    TaskDialog.Show("Info", "Family view not open.");
}&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;Everything works as it should up until UploadOriginal method call.&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;string path = Path.GetTempPath();
string name = family.Name;
string fName = name + ".rfa";
string fPath = path + fName;
&lt;BR /&gt;//Revit throws an error on this line saying that Family is not editable&lt;BR /&gt;//What could cause this mayhem?&lt;BR /&gt;//To upload .rfa Family file I need to save it as a file first and that's what I try to do until mighty ERROR occurs
Document famDoc = doc.EditFamily(family);
famDoc.SaveAs(fPath);
famDoc.Close(false);
//application related code following...&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What could be the reason of this error? How could I fix it? Must it be overwritten like a baus (&lt;A href="https://www.youtube.com/watch?v=NisCkxU544c" target="_blank"&gt;BOSS&lt;/A&gt;)?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Sep 2014 07:43:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/saving-family-after-editing-with-familymanager/m-p/5291581#M75608</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-09-23T07:43:56Z</dc:date>
    </item>
    <item>
      <title>Re: Saving family after editing with FamilyManager</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/saving-family-after-editing-with-familymanager/m-p/5291671#M75609</link>
      <description>&lt;P&gt;Dear Raunoveb,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I implemented an add-in to update fonts in loaded families yesterday.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For some of the loaded families, EditFamily threw that same exception saying "Family is not editable".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I added an exception handler to skip them:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;  try
  {
    r1.FamilyDocument
      = doc.EditFamily( f );

  }
  catch( Autodesk.Revit.Exceptions.ArgumentException ex )
  {
    r1.Skipped = true;
    results.Add( r1 );
    Debug.Print( "Family '{0}': {1}", f.Name, ex.Message );
    continue;
  }&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is an excerpt of the add-in log; the families marked 'skipped' are the ones I mean:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://forums.autodesk.com/t5/image/serverpage/image-id/126933i6C809B3F373237FE/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="result_message.png" title="result_message.png" align="center" /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I simply assumed that is normal.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;p.s. cool video &amp;nbsp;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Sep 2014 08:40:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/saving-family-after-editing-with-familymanager/m-p/5291671#M75609</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2014-09-23T08:40:27Z</dc:date>
    </item>
    <item>
      <title>Re: Saving family after editing with FamilyManager</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/saving-family-after-editing-with-familymanager/m-p/5291719#M75610</link>
      <description>&lt;P&gt;I managed to skip those families by simply adding if(family.IsEditable) block around the code. Unfortunately for us these families we try to process must be processed so we can't just skip them.&lt;/P&gt;&lt;P&gt;I've had 2 ideas that could explain those errors:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;FamilyManager (fm) somehow locks the family currently open in Family Document and only allows us to Edit the family after it's released the family. However even after fm.Dispose() the EditFamily method threw that exception.&lt;/LI&gt;&lt;LI&gt;(This idea could be related to first idea). One cannot just simply write a family to file just after the shared parameters have been changed/added. A "save" command must be somehow executed in order to "unlock" this family. However once again I found no methods in either FamilyManager or Family class that would allows us to do that.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;I have danced around this problem for 3 days and have ran out of ideas. Any help "unlocking" these families would be greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Sep 2014 09:02:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/saving-family-after-editing-with-familymanager/m-p/5291719#M75610</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-09-23T09:02:44Z</dc:date>
    </item>
    <item>
      <title>Re: Saving family after editing with FamilyManager</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/saving-family-after-editing-with-familymanager/m-p/5291803#M75611</link>
      <description>&lt;P&gt;Dear Raunoveb,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much for pointing out the IsEditable predicate. I successfully replaced my exception handler by simply checking that instead.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regarding your locked families, have you tried ensuring that absolutely no other documents are open, only the one and only family that you are trying to modify?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;</description>
      <pubDate>Tue, 23 Sep 2014 09:34:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/saving-family-after-editing-with-familymanager/m-p/5291803#M75611</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2014-09-23T09:34:11Z</dc:date>
    </item>
    <item>
      <title>Re: Saving family after editing with FamilyManager</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/saving-family-after-editing-with-familymanager/m-p/5291843#M75612</link>
      <description>&lt;P&gt;Thanks for your comment about any other open documents. I suddenly realized that in my main program I already had FamilyDocument open. When I used UploadOriginal() method I gave&amp;nbsp;&lt;EM&gt;doc&lt;/EM&gt; as an input and then tried:&lt;/P&gt;&lt;PRE&gt;var famDoc = doc.EditFamily(family);
famDoc.SaveAs(path);
famDoc.Close(false);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;That created another Family Document instance of the same family and that's why it threw this "Family not editable" exception. I changed it to:&lt;/P&gt;&lt;PRE&gt;doc.SaveAs(path);
//Can't close it since I have this family view open in Revit and API &lt;BR /&gt;//doesn't have permission to close visibly open documents in Revit.
//doc.Close(false);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;However now I've got problems with getting the Family.Name value from &lt;EM&gt;doc&lt;/EM&gt;.OwnerFamily.Name. It always returns "" and all the files saved look like this "/folder/.rfa", when they should look something like this "/folder/NightLamp.rfa"&lt;/P&gt;</description>
      <pubDate>Tue, 23 Sep 2014 10:03:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/saving-family-after-editing-with-familymanager/m-p/5291843#M75612</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-09-23T10:03:39Z</dc:date>
    </item>
    <item>
      <title>Re: Saving family after editing with FamilyManager</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/saving-family-after-editing-with-familymanager/m-p/5291847#M75613</link>
      <description>&lt;P&gt;Dear Raunoveb,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cool.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Progress.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How about using the document title instead of the family name?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;</description>
      <pubDate>Tue, 23 Sep 2014 10:09:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/saving-family-after-editing-with-familymanager/m-p/5291847#M75613</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2014-09-23T10:09:31Z</dc:date>
    </item>
    <item>
      <title>Re: Saving family after editing with FamilyManager</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/saving-family-after-editing-with-familymanager/m-p/5291873#M75614</link>
      <description>&lt;P&gt;Using doc.Title did the trick. However it's weird that OwnerFamily.Name returned blank response.&lt;/P&gt;&lt;P&gt;Thanks for everything. And since your second answer provided most help regarding to the main question I'll mark that one as a solution.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Sep 2014 10:25:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/saving-family-after-editing-with-familymanager/m-p/5291873#M75614</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2014-09-23T10:25:46Z</dc:date>
    </item>
    <item>
      <title>Re: Saving family after editing with FamilyManager</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/saving-family-after-editing-with-familymanager/m-p/5291935#M75615</link>
      <description>&lt;P&gt;Dear Raunoveb,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cooler still.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That was a quick solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for marking the solution and for the interesting discussion.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;</description>
      <pubDate>Tue, 23 Sep 2014 11:03:15 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/saving-family-after-editing-with-familymanager/m-p/5291935#M75615</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2014-09-23T11:03:15Z</dc:date>
    </item>
    <item>
      <title>Re: Saving family after editing with FamilyManager</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/saving-family-after-editing-with-familymanager/m-p/5294779#M75616</link>
      <description>&lt;P&gt;Dear Raunoveb,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I published another discussion on&amp;nbsp;modifying, saving and reloading families on The Building Coder today:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://thebuildingcoder.typepad.com/blog/2014/09/modifying-saving-and-reloading-families.html" target="_blank"&gt;http://thebuildingcoder.typepad.com/blog/2014/09/modifying-saving-and-reloading-families.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since this thread&amp;nbsp;is related to that, I summarised it there as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;</description>
      <pubDate>Wed, 24 Sep 2014 11:03:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/saving-family-after-editing-with-familymanager/m-p/5294779#M75616</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2014-09-24T11:03:34Z</dc:date>
    </item>
  </channel>
</rss>

