Set Formula in Family

Set Formula in Family

Anonymous
Not applicable
1,444 Views
4 Replies
Message 1 of 5

Set Formula in Family

Anonymous
Not applicable

Hello All!

 

I was browsing around the api documentation and found a SetFormula method but am not quite sure how it used. I am wanting to set the formula for a specific family. But my searches on the forum and elsewhere of google have not yielded many results unless I am not understanding something. How would I get a specific family in a project, then set the formula on the family?

 

Something like MyTestFamily.SetFormula mytestFormulaField myformula

 

Thanks in advance all!

0 Likes
Accepted solutions (1)
1,445 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable

Hello Samuel,

 

Well, first I think you need to actually use that on a Family document type. See this link:

 

http://thebuildingcoder.typepad.com/blog/2009/11/family-parameter-value.html

 

And then you could use that formula in the family you want

 

http://www.revitapidocs.com/2015/cdc3156c-0334-0bba-70af-1df78fb18b50.htm

 

Cheers

0 Likes
Message 3 of 5

Anonymous
Not applicable

Ok, I am beginning to understand now. Is there anyway to specifically load a family via the API? like search for it in the project. Something like

 

Family myFamily = new MyTestFamily()

 

From what I am understanding, the method you linked (which was a great resource I am going to use that for sure) only works via user input and when they are currently looking at the document. Is there anyway I can automate that process?

 

Thank you for the reply! Im fairly proficient in programming, but still learning the ropes of Revit.

0 Likes
Message 4 of 5

Anonymous
Not applicable
Accepted solution

Hello Samuel,

 

In order to automatize, perhaps try using the 

 

FilteredElementCollector families
      = new FilteredElementCollector( doc )
        .OfClass( typeof( Family ) );

To get all families in the project, and then use a foreach loop

 

foreach( Family f in families )
    {
// do your thing
}

 

Inside the foreach, you select the family you want to work on, or work on all of them. By the way, all this info is in this link:

 

http://thebuildingcoder.typepad.com/blog/2014/09/modifying-saving-and-reloading-families.html

 

 

Cheers

Ruben

Message 5 of 5

Anonymous
Not applicable

Awesome Thank you! I will look into implementing that. I appreciate all the help 😄 I will also take another look at that link for things that I most likely (and obviously) missed.

 

Thanks!

0 Likes