Hi
Yeah it was looking odd to me as well, but I fount it in the example code in the Revit API Docs website and I took it as it was...I guess they were probably showing three different possibilities?from Revit API Doc
Anyways, I deleted that part (latest code copied below) but it is still not working...again, it starts calculating and it gives the progress bar saying it is doing something with that file but then nothing happens. What am I doing wrong??
#region Namespaces using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Text; using System.Collections; using System.Linq; using Autodesk.Revit.ApplicationServices; using Autodesk.Revit.Attributes; using Autodesk.Revit.DB; using Autodesk.Revit.UI; using Autodesk.Revit.UI.Selection; using Autodesk.Revit.Creation; #endregion namespace LinkRVT_test { [Transaction(TransactionMode.Manual)] public class Command : IExternalCommand { public Result Execute( ExternalCommandData commandData, ref string message, ElementSet elements) { // Get application and document objects UIApplication uiapp = commandData.Application; UIDocument uidoc = uiapp.ActiveUIDocument; Autodesk.Revit.ApplicationServices.Application app = uiapp.Application; Autodesk.Revit.DB.Document doc = uidoc.Document; try { using (Transaction transaction = new Transaction(doc)) { transaction.Start("Link files"); string testFile = @"C:\Users\atassera\AT\C#\Revit\LinkRVT_test\Utilities\AR-GAM-3DM-FACADE-RVT.rvt"; ModelPath linkpath = ModelPathUtils.ConvertUserVisiblePathToModelPath(testFile); RevitLinkOptions options = new RevitLinkOptions(false); RevitLinkLoadResult result = RevitLinkType.Create(doc, linkpath, options); RevitLinkInstance.Create(doc, result.ElementId); transaction.Commit(); return Result.Succeeded; } } catch (Autodesk.Revit.Exceptions.OperationCanceledException) { // If user decided to cancel the operation return Result.Canceled return Result.Cancelled; } catch (Exception ex) { // If something went wrong return Result.Failed Console.WriteLine("There was a problem!"); Console.WriteLine(ex.Message); return Result.Failed; } } } }
Thanks guys, any suggestion and clarification is very well appreciated!
Cheers,
Andrea