I'm looking for a way (may not be possible) to get a Revit file from the Autodesk Desktop Connector to a Document class so I won't have to use the cloud API's.
The code below doesn't compile but does represented the genral idea, any thoughts ?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using Autodesk.Connectivity.WebServices;
using Autodesk.Connectivity.WebServicesTools;
using Autodesk.Revit.DB;
namespace ConsoleApp1
{
internal class Program
{
static void Main(string[] args)
{
// Set up connection to the Autodesk Desktop Connector
WebServiceManager serviceManager = WebServiceManager.GetServiceManager();
string ticket = serviceManager.SecurityService.Authenticate();
// Get the list of files in the Autodesk Desktop Connector
File[] files = serviceManager.DocumentService.FindFiles(ticket, "*.rvt");
// Open the first Revit file in the list
Document doc = Autodesk.Revit.ApplicationServices.Application.OpenDocumentFile(files[0].path);
}
}
}
No, you cannot access the Revit Document
class from such an external context. To access it, you need to be in a valid Revit API context:
Such a context is either provided by running Revit.exe
on your Windows desktop and installing an add-in implementing the requisite Revit API event handlers, or by making use of the Autodesk Platform Services APS (formerly Forge) Design Automation API.