So it’s here, the day that all of you Apple lovers (including myself) have been waiting for (again for another year). The announcement of a new mobile device it is only a couple of hours away and rumors says that a possible iWatch will be announced as well. Let’s see if Jony Ive’s quote “Switzerland is in trouble” will fulfill our expectations of a good watch. Here is a list of Apple Event Essentials to follow.
Back to Revit. Today’s post came from the Autodesk forum, and it is regarding the use of a new class implemented in the 2015 SDK.
http://forums.autodesk.com/t5/revit-api/keybasedtreeentrytable-reload/td-p/5251297
Question: I am trying to create a simple button that reloads the Keynotes file. Not sure how to code it as I have not coded in Revit. I did my first Revit plugin, but I am not sure how to call this function.
KeyBasedTreeEntryTable.Reload();
I take I need better understanding of the public result execute.
thanks
public Result Execute(
ExternalCommandData commandData,
ref string message,
ElementSet elements)
{
//Get application and document objects
UIApplication uiApp = commandData.Application;
Document doc = uiApp.ActiveUIDocument.Document;
KeyBasedTreeEntryTable.Reload();
return Result.Succeeded;
}
Unfortunately the way the reload function is being used there will not be the correct one.
The answer came from one of our great Revit Engineers.
Answer: If what you want is just to reload the keynote table from its current location, you should:
1.) Call KeynoteTable.GetKeynoteTable(Document doc). This is a static function which will get you the document's keynote table. (You will need to pass in the current document as an argument.)
2.) Then you can call Reload() on the keynote table object.
If you want to reload the keynote table from a different location, you should call LoadFrom instead. That function takes in an ExternalResourceReference argument. If you want to load the table from a normal file on disk, you can create an ExternalResourceReference via ExternalResourceReference.CreateLocalResource.
Here is a snippet of code simply showing the 2 steps from the answer above on how to use the reload function from its current location on a command call, nothing too fancy.
public Result Execute(
ExternalCommandData commandData,
ref string message,
ElementSet elements)
{
UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Application app = uiapp.Application;
Document doc = uidoc.Document;
Transaction tr = new Transaction(doc, "Reload");
tr.Start();
KeynoteTable.GetKeynoteTable(doc).Reload(null);
tr.Commit();
return Result.Succeeded;
}
Thanks for reading, until next time.