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 Overwirte Issue

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
sankar_g
844 Views, 2 Replies

Family Overwirte Issue

Hi,

 

           I would like to overwrite a familySymbol  available in the document when document opened event. The familySymbol is not available in the family text file  (i.e) familySymbol is available only in document.

 

          I tried LoadFamilySymbol() method with IFamilyLoadOptions arguments, it returns false and familySymbol as null. I dont want to create the symbol in family text file and i need only to update the familysymbol available in the document.

 

          Could anyone help me to solve this issue.

 

Regards,

sangsen

 

 

2 REPLIES 2
Message 2 of 3
atiefenbach
in reply to: sankar_g

If you're trying to overwrite a FamilySymbol you could just find the one you're trying to chanage, start a Transaction, and then edit the parameters.  No reason to reload the family at all, unless it's a different version.  If you need to make a new Type of that family, you can just Duplicate the first FamilySymbol and then change the parameters.

Anthony Tiefenbach
BIM Manager
HuntonBrady Architects
Message 3 of 3
Lucavox
in reply to: sankar_g

Hi,

 

This is a short code to Load a family in the document knowing the path and the type name you need:

 

string path = @"c:\familyfile.rfa";

string name = "Type name";
			
//You need to set the path and type name correctly

Transaction t = new Transaction(Document, "load_my_symbol");
	
t.Start();
			
Document.LoadFamilySymbol(path, name);
			
t.Commit();

 

I don't understand if you need to replace instances within the project. But if you need to use FamilyLoadoptions the code below could be helpful:

 - First build the class

 

public class familyloadoptions : IFamilyLoadOptions
   		{
        #region IFamilyLoadOptions Members

        public bool OnFamilyFound(bool familyInUse, out bool overwriteParameterValues)
        {
            if( !familyInUse )
            {
                overwriteParameterValues = true;
                return true;
            }
            else
            {
                overwriteParameterValues = true;
                return true;
            }
        }

        public bool OnSharedFamilyFound(Family sharedFamily, bool familyInUse, out FamilySource source, out bool overwriteParameterValues)
        {
            if (!familyInUse)
            {
                source = FamilySource.Family;
                overwriteParameterValues = true;
                return true;
            }
            else
            {
             	source = FamilySource.Family;
                overwriteParameterValues = true;
                return true;
            }
        }

        #endregion
    }

 

 Here the code of the command:

 

 

			string path = @"c:\familyfile.rfa";
			string name =  "Type name";
			
			Transaction t = new Transaction(Document, "load_my_symbol");
			t.Start();
			
			FamilySymbol symb;
			
			
			
			Document.LoadFamilySymbol(path, name, new familyloadoptions(), out symb);
			
			t.Commit();

 

Kind regards,

Luca Vocella

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