-
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
3 changed files
with
88 additions
and
5 deletions.
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
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,72 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.Globalization; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Net.Sockets; | ||
using System.Windows; | ||
using Autodesk.Revit.Attributes; | ||
using Autodesk.Revit.DB; | ||
using Autodesk.Revit.UI; | ||
using CsvHelper; | ||
using Microsoft.Win32; | ||
|
||
namespace Test; | ||
|
||
[Transaction(TransactionMode.Manual)] | ||
public class OpenModelFromCloudSimple : IExternalCommand | ||
{ | ||
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) | ||
{ | ||
// open model from acc | ||
var doc = commandData.Application.ActiveUIDocument.Document; | ||
string region = "US"; | ||
var projectGuid = new Guid("f10b5c85-fd34-435a-9206-e4a8c21d761c"); | ||
var modelGuid = new Guid("119d11f3-4d92-4d50-81db-0a03aa20fd82"); | ||
var modelPath = ModelPathUtils.ConvertCloudGUIDsToCloudPath(region, projectGuid, modelGuid); | ||
// Document document = doc.Application.OpenDocumentFile(modelPath, new OpenOptions()); | ||
// active document | ||
commandData.Application.OpenAndActivateDocument(modelPath, new OpenOptions(), false); | ||
// sync model | ||
// close model | ||
doc.Close(false); | ||
|
||
return Result.Succeeded; | ||
|
||
} | ||
public void OpenLogFileAndWrite(string message) | ||
{ | ||
string fileName = "log.txt"; | ||
string logFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), fileName); | ||
if (!File.Exists(logFile)) | ||
{ | ||
using (StreamWriter sw = File.CreateText(logFile)) | ||
{ | ||
sw.WriteLine(message); | ||
} | ||
} | ||
else | ||
{ | ||
using (StreamWriter sw = File.AppendText(logFile)) | ||
{ | ||
sw.WriteLine(message); | ||
} | ||
} | ||
} | ||
public string BrowsePath() | ||
{ | ||
var dialog = new OpenFileDialog(); | ||
dialog.Filter = "Revit Files (*.csv)|*.csv"; | ||
dialog.Title = "Select a items file"; | ||
dialog.ShowDialog(); | ||
return dialog.FileName; | ||
} | ||
public class DataInput | ||
{ | ||
public string item_id { get; set; } | ||
public string item_name { get; set; } | ||
public string project_guid { get; set; } | ||
public string model_guid { get; set; } | ||
} | ||
} |
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