Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

KeyBasedTreeEntryTable.Reload()

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
BIMologist_
1262 Views, 4 Replies

KeyBasedTreeEntryTable.Reload()

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 / Dr. Revit
Approved Autodesk Services Marketplace provider - BIM Consulting

EESignature


If you find this reply helpful, please use the Accept Solution or Like button below
4 REPLIES 4
Message 2 of 5
rosalesduquej
in reply to: BIMologist_

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
Message 3 of 5

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_
in reply to: rosalesduquej

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 / Dr. Revit
Approved Autodesk Services Marketplace provider - BIM Consulting

EESignature


If you find this reply helpful, please use the Accept Solution or Like button below
Message 5 of 5

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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community