Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi i'm trying to place a family from a plug in i created; however, i'm getting a warning saying "Placement is not permitted in an already modifiable document. The active transaction must be closed first". Then as i continue further, it's returning "Starting a transaction from external application running outside of the API is not allowed"
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using System.Collections.ObjectModel;
using System.Linq;
using System.Collections.Generic;
namespace Plugin.Revit
{
public class FamilyLibraryModel
{
public UIApplication uiapp { get; }
public Document doc { get; }
public UIDocument uidoc { get; }
public FamilyLibraryModel(UIApplication uiApp)
{
uiapp = uiApp;
doc = uiApp.ActiveUIDocument.Document;
uidoc = uiApp.ActiveUIDocument;
}
public void Place(IEnumerable<RevitFamilyWrapper> selected)
{
var selectedFamilySymbol = selected.Select(x=>x.familySymbol).First();
using (var trans = new Transaction((doc), "Place Family"))
{
trans.Start();
uidoc.PromptForFamilyInstancePlacement(selectedFamilySymbol);
trans.Commit();
}
}
}
}
i'm not quite sure where i'm doing wrong, would appreciate any insights!
Solved! Go to Solution.