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
using System;
using System.Collections.Generic;
using System.Linq;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Architecture;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
[TransactionAttribute(TransactionMode.Manual)]
[RegenerationAttribute(RegenerationOption.Manual)]
publicclassRevitKeynoteReload : IExternalCommand
{
publicResult Execute(
ExternalCommandData commandData,
refstring message,
ElementSet elements)
{
//Get application and document objects
UIApplication uiApp = commandData.Application;
Document doc = uiApp.ActiveUIDocument.Document;
KeyBasedTreeEntryTable.Reload()
returnResult.Succeeded;
}
}
Solved! Go to Solution.
Solved by BIMologist_. Go to Solution.
Solved by rosalesduquej. Go to Solution.
Hi,
I raised your question to our Revit engineers and this is the response I got from them. Let us know how it goes. Good luck.
------------------------------------
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.
-----------------------------------
Hope it helps.
Cheers,
Try this and let me know, its a simple command that you can chop off and added to where you have your button action. I bolded the important parts that you will need. hope it helps.
namespace TestReloadSample
{
[Transaction(TransactionMode.Manual)]
publicclassCommand : IExternalCommand
{
publicResultExecute(
ExternalCommandDatacommandData,
refstringmessage,
ElementSetelements)
{
UIApplicationuiapp=commandData.Application;
UIDocumentuidoc=uiapp.ActiveUIDocument;
Autodesk.Revit.ApplicationServices.Applicationapp=uiapp.Application;
Documentdoc=uidoc.Document;
Transactiontr=newTransaction(doc, "Reload");
tr.Start();
KeynoteTable.GetKeynoteTable(doc).Reload(null);
tr.Commit();
returnResult.Succeeded;
}
}
}
Cheers,
Thanks so much for the guidance.
I am just going to post the cleaned up version as it took me a bit to figure ou t the spaces the website eliminated in your solution
namespace RevitKeynoteReload
{
[TransactionAttribute(TransactionMode.Manual)]
[RegenerationAttribute(RegenerationOption.Manual)]
public class Command : IExternalCommand
{
public Result Execute(
ExternalCommandData commandData,
ref string message,
ElementSet elements)
{
UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Autodesk.Revit.ApplicationServices.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;
}
}
}
Can't find what you're looking for? Ask the community or share your knowledge.