-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
41 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System; | ||
using System.IO; | ||
using Autodesk.Revit.Attributes; | ||
using Autodesk.Revit.DB; | ||
using Autodesk.Revit.UI; | ||
|
||
namespace Test; | ||
|
||
[Transaction(TransactionMode.Manual)] | ||
public class OpenModelAndSync : IExternalCommand | ||
{ | ||
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) | ||
{ | ||
var doc = commandData.Application.ActiveUIDocument.Document; | ||
string region = "US"; | ||
var projectGuid = new Guid("f10b5c85-fd34-435a-9206-e4a8c21d761c"); | ||
string input = @"D:\API\Revit\RevitAddInManager\Test\Sample\data\input.txt"; | ||
string guidModelInput = File.ReadAllText(input).Trim(); | ||
var modelGuid = new Guid(guidModelInput); | ||
var modelPath = ModelPathUtils.ConvertCloudGUIDsToCloudPath(region, projectGuid, modelGuid); | ||
// Document document = doc.Application.OpenDocumentFile(modelPath, new OpenOptions()); | ||
// active document | ||
Document document = doc.Application.OpenDocumentFile(modelPath, new OpenOptions()); | ||
// reload latest | ||
document.ReloadLatest(new ReloadLatestOptions() { }); | ||
// sync model | ||
TransactWithCentralOptions twcOpts = new TransactWithCentralOptions(); | ||
SynchronizeWithCentralOptions syncopt = new SynchronizeWithCentralOptions(); | ||
RelinquishOptions rOptions = new RelinquishOptions(true); | ||
rOptions.UserWorksets = true; | ||
syncopt.SetRelinquishOptions(rOptions); | ||
// syncopt.SaveLocalBefore = false; | ||
// syncopt.SaveLocalAfter = false; | ||
document.SynchronizeWithCentral(twcOpts, syncopt); | ||
// publish model post command | ||
// close model | ||
document.Close(false); | ||
return Result.Succeeded; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
a449f572-5520-448b-8ef8-ed9eee240694 | ||
9a6fb2f5-26e5-47a4-aa3f-587003c6e43b |