I'm having a problem with the method uidoc.PostRequestForElementTypePlacement()
.
It seems that the method is always requesting to use the architectural placement instead of the structural one. Is there any way to call the structural wall/floor placement?
Or is it possible to wait for the user to place with the method en then set the parameter "Structural" to true afterwards? I'm not sure how to do this as the above method does not get executed immediately but instead when the user brings focus back to the Revit view.
Thanks in advance.
Edit, added minimal code:
using System;
using System.Collections.Generic;
using System.Linq;
using Autodesk.Revit.DB;
using Autodesk.Revit.DB.Events;
using Autodesk.Revit.UI;
using Autodesk.Revit.Attributes;
namespace Test2
{
[TransactionAttribute(TransactionMode.Manual)]
[RegenerationAttribute(RegenerationOption.Manual)]
public class Test2 : IExternalCommand
{
List<ElementId> addedElementIds = new List<ElementId>();
UIApplication _uiapp;
public Result Execute(
ExternalCommandData commandData,
ref string message,
ElementSet elements)
{
UIApplication uiApp = commandData.Application;
Autodesk.Revit.ApplicationServices.Application app = uiApp.Application;
UIDocument uiDoc = uiApp.ActiveUIDocument;
Document doc = uiDoc.Document;
_uiapp = uiApp;
addedElementIds.Clear();
WallType wallType = new FilteredElementCollector(doc).OfClass(typeof(WallType)).Cast<WallType>().Last();
app.DocumentChanged += new EventHandler<DocumentChangedEventArgs>(OnDocumentChanged);
uiDoc.PostRequestForElementTypePlacement(wallType);
return Result.Succeeded;
}
void OnDocumentChanged(object sender, DocumentChangedEventArgs e)
{
addedElementIds.AddRange(e.GetAddedElementIds());
Autodesk.Revit.ApplicationServices.Application app = _uiapp.Application;
Document doc = _uiapp.ActiveUIDocument.Document;
foreach (ElementId id in addedElementIds)
{
Element el = doc.GetElement(id);
el.LookupParameter("Structural").Set(1);
}
app.DocumentChanged -= new EventHandler<DocumentChangedEventArgs>(OnDocumentChanged);
}
}
}