Keynote Files

Keynote Files

Anonymous
Not applicable
647 Views
6 Replies
Message 1 of 7

Keynote Files

Anonymous
Not applicable

Hi,

 

I am currently using Revit 2015. I am working on a routine that copies my company's standard keynote file to my central model's location and renaming based on the project number parameter. Is it possible to take it a step farther and apply that keynote file to the model?

0 Likes
648 Views
6 Replies
Replies (6)
Message 2 of 7

PhillipM
Advocate
Advocate

Sure you can.  Code below.

 

Dim p As ModelPath = ModelPathUtils.ConvertUserVisiblePathToModelPath(My.Computer.FileSystem.SpecialDirectories.Temp + "\tmpknFile.txt")

            Dim s As ExternalResourceReference = ExternalResourceReference.CreateLocalResource(commandData.Application.ActiveUIDocument.Document, ExternalResourceTypes.BuiltInExternalResourceTypes.KeynoteTable, p, PathType.Absolute)
            t = New Transaction(commandData.Application.ActiveUIDocument.Document, "Reload")
            t.Start()
            knTable.LoadFrom(s, Nothing)
            t.Commit()
Message 3 of 7

Anonymous
Not applicable

Thank you! I believe in the past this was considered not possible.

 

ModelPath p = ModelPathUtils.ConvertUserVisiblePathToModelPath("whatever:\\whatever\\KeyNotes"+ "\\TheUserKeyNotesFile.txt");
			ExternalResourceReference  s = ExternalResourceReference.CreateLocalResource(doc, ExternalResourceTypes.BuiltInExternalResourceTypes.KeynoteTable, p, PathType.Absolute);
     			try {
			        		using (Transaction t = new Transaction(doc, "UserKeynoteFileReload")){ 
							t.Start(); 
							KeynoteTable.GetKeynoteTable(doc).LoadFrom(s,null);
							t.Commit(); 
						} 
			        	} catch (Exception) {
			        		throw;
			        	}
0 Likes
Message 4 of 7

PhillipM
Advocate
Advocate

Only available in 2015 & Above

0 Likes
Message 5 of 7

Anonymous
Not applicable
Is there any reason that I couldn't use this code to reload the keynote file?
0 Likes
Message 6 of 7

PhillipM
Advocate
Advocate

Reloading is even easier.

 

 Dim knTable As KeynoteTable = Autodesk.Revit.DB.KeynoteTable.GetKeynoteTable(doc)
        Dim lr As New KeyBasedTreeEntriesLoadResults
        Dim t As New Transaction(doc, "Reload")
        t.Start()
        knTable.Reload(lr)
        t.Commit()
Message 7 of 7

Anonymous
Not applicable

Reason could not, I don't know. I changed to use the Reload method instead of the LoadFrom but I am still verifying the file exists before Reloading so that the message to the user can be more informative.

0 Likes