KeyBasedTreeEntryTable.Reload()

KeyBasedTreeEntryTable.Reload()

BIMologist_
Collaborator Collaborator
1,505 Views
4 Replies
Message 1 of 5

KeyBasedTreeEntryTable.Reload()

BIMologist_
Collaborator
Collaborator

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;

 

}

 

}

 

 

 

BIMologist
- Nauman Mysorewala
Did you find this post
helpful? Feel free to like this post.
Did your question get successfully answered? Then click
on the ACCEPT SOLUTION button.


EESignature

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

rosalesduquej
Alumni
Alumni

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,



Jaime Rosales D.
Sr. Developer Consultant
Twitter | AEC ADN DevBlog
0 Likes
Message 3 of 5

rosalesduquej
Alumni
Alumni
Accepted solution

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,



Jaime Rosales D.
Sr. Developer Consultant
Twitter | AEC ADN DevBlog
Message 4 of 5

BIMologist_
Collaborator
Collaborator
Accepted solution

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;

  }

}

}

 

 

 

BIMologist
- Nauman Mysorewala
Did you find this post
helpful? Feel free to like this post.
Did your question get successfully answered? Then click
on the ACCEPT SOLUTION button.


EESignature

Message 5 of 5

Anonymous
Not applicable
Hi,
How can I simply loadfrom() from a file path, i am unaware of the structure of ExternalResourceReference.CreateLocalResource
0 Likes