The Revit ribbon is context sensitive, so it switches to specific tabs under specific circumstances. For instance, if I select a wall in the model, it switches to the Modify Walls tab. This may seem like a limitation for add-ins, since all add-in commands are placed in the Add-Ins tab.
Imagine I have an add-in which provides a command specific to walls. Ideally, I would like my command to be added to the walls Modify Walls tab. That is unfortunately currently not possible.
One thing to be aware of, however, is that each individual panel of the ribbon can be dragged out of the ribbon area onto the graphics screen, in which case it remains visible even when tabs are switched. So as a partial workaround, I can place my add-in's wall specific commands in a separate panel and then drag that out onto the graphics screen to have simultaneous access to the standard modify walls commands and my add-in wall commands. Here is an example showing a highlighted selected wall, the activated Modify Walls tab, and the panel defined by the Revit SDK Ribbon sample floating on to the graphics screen for immediate access to those commands as well:
Here is another question that pops up now and then, and once again the strong hint to look at the API documentation in the SDK when searching for information:
Question: Can I use the Revit API to just load one single selected type of a family into a project? A family may define many types, but the project only requires one of them. Is it possible to just load just that one type?
Answer: If you look in the Revit API help file for "load family", the first hit returned is the Document.LoadFamily method. It loads an entire family and all its types or symbols into the document. The remarks to this method include the following note:
Loading an entire family may take a considerable amount of time and memory. It is recommended that you use LoadFamilySymbol and only load those symbols that you need. The path to the installed Autodesk Revit family files can be found by using the Application.Options object and its methods.
So, as it says, you can use the API method LoadFamilySymbol to load the specific family symbol that you are interested in instead of the entire family.
Hello Jeremy,
I couldn't find an appropriate place to contact you so I'll post here.
I'm having trouble updating the revit options for library paths, below is my code. I'm not sure what I'm missing to updating back to the database.
public class AddLibraryPaths : IExternalCommand
{
public CmdResult Execute(
ExternalCommandData commandData,
ref string message,
ElementSet elements )
{
try
{
Application app = commandData.Application;
Document doc = app.ActiveDocument;
// string LibraryPaths = "";
string strLibPaths = "";
int count = 0;
foreach (String path in app.Options.LibraryPaths)
{
strLibPaths += path + "\n";
count +=count;
//strLibPaths = path.Substring(1);
}
count ++;
string MetricLibraryKey = "";
MetricLibraryKey = app.Options.LibraryPaths.get_Item("Metric Library");
app.Options.LibraryPaths.Insert("ImperialTestCreate", "C:\'Documents and Settings\'All Users\'Application Data\'Autodesk\'RAC 2010\'Imperial Library\'Detail Components");
app.Options.LibraryPaths.set_Item("ImperialTestCreate","C:\'Temp");
// app.Options.LibraryPaths.Equals(app.Options.LibraryPaths);
// app.Options.LibraryPaths.IsReadOnly;
Util.InfoMsg( string.Format(strLibPaths+MetricLibraryKey));
return CmdResult.Succeeded;
}
catch( Exception ex )
{
message = ex.Message;
return CmdResult.Failed;
}
}
}
Any advice would be greatly appreciated!
Posted by: Edgar | August 19, 2009 at 17:31
Dear Edgar,
Thank you for your interesting question. Posting a comment here on the blog is a fine way to contact me. I have created a draft for a new blog post to answer your question and mailed it to you directly for reviewing.
Cheers, Jeremy.
Posted by: Jeremy Tammik | August 19, 2009 at 19:28
Dear Edgar,
The post is published now:
http://thebuildingcoder.typepad.com/blog/2009/08/library-paths.html
Thank you again for your question, review and feedback.
Cheers, Jeremy.
Posted by: Jeremy Tammik | August 21, 2009 at 06:38
Hi Jeremy,
I've looked around and haven't found a way to do this yet. As we've been creating content for Revit, we've been saving our Symbols/Types into a txt file. LoadFamilySymbol works great if the Revit Types are built into the rfa file but when they are separated out into a txt file, it doesn't work. Is there a way to load a single family when they are separated out into a txt file?
Thanks for time/assistance!!
Matt
Posted by: Matt Landress | March 11, 2010 at 08:04
Dear Matt,
Please pardon my ignorance, but I thought a TXT file was always just associated with an RFA file, and all it did was define a list of additional combinations of parameters to define specialised types?
I have heard of cases where people wanted to load a specific symbol that was defined in such a pair of RFA plus TXT file and used LoadFamilySymbol successfully, so I don't quite understand what is not working for you?
One way to circumvent any possible problems with the TX file would be to just define one single type in the RFA file, load that, and then use the Duplicate method to create any other types that you need, as explained in
http://thebuildingcoder.typepad.com/blog/2008/11/creating-a-new-family-symbol.html
The technique is used to create new column and beam types in
http://thebuildingcoder.typepad.com/blog/2009/02/inserting-a-column.html
http://thebuildingcoder.typepad.com/blog/2009/02/inserting-a-beam.html
Cheers, Jeremy.
Posted by: Jeremy Tammik | March 17, 2010 at 11:46
Dear Jeremy,
I have been trying to load a family type and then create an instance of that family type but I can't get pass of the FamilySymbol issue. How do I get this object? I want to insert isolated foundations "M_Pile Cap-Rectangular : 1400 x 1300 x 350mm". How do I get the FamilySymbol for this? I have been going through your blog, API Labs and the Developer Guide and I can't find an answer.
Thank you.
Best regards,
Vasco Granadeiro
Posted by: Vasco Granadeiro | June 22, 2010 at 15:49
Dear Vasco,
You will definitely need to hone up your searching skills a bit.
How about using the GetFirstFamilySymbol method in this recent post as a starting point:
http://thebuildingcoder.typepad.com/blog/2010/06/set-tag-type.html
If you need to search for the symbol by name, there are several previous posts which show exactly how to do this.
Cheers, Jeremy.
Posted by: Jeremy Tammik | June 25, 2010 at 05:20