Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Revit 2023. Attempting to batch join wall and floors, using "DialogBoxShowingEventArgs" to suppress this warning by setting the override result to commandlink1, or unjoin elements.
the code thus far:
namespace Batch_Switch_Join_Order
{
[Transaction(TransactionMode.Manual)]
public class BatchSwitcherooo : IExternalCommand
{
public Result Execute(ExternalCommandData commdata, ref string msg, ElementSet elemset)
{
UIApplication _uiapp = commdata.Application;
UIDocument _uidoc = commdata.Application.ActiveUIDocument;
Document _doc = _uidoc.Document;
_uiapp.DialogBoxShowing += new EventHandler<DialogBoxShowingEventArgs>(Dialogboxshower);
List<Element> walls = new FilteredElementCollector(_doc).OfCategory(BuiltInCategory.OST_Walls).WhereElementIsNotElementType().ToList();
List<Element> floors = new FilteredElementCollector(_doc).OfCategory(BuiltInCategory.OST_Floors).WhereElementIsNotElementType().ToList();
using (TransactionGroup trg = new TransactionGroup(_doc))
{
trg.Start("theJoining");
foreach (Element wall in walls)
{
foreach (Element floor in floors)
{
using (Transaction tr = new Transaction(_doc))
{
tr.Start("Joining");
try
{
JoinGeometryUtils.JoinGeometry(_doc, wall, floor);
//JoinGeometryUtils.SwitchJoinOrder(_doc, wall, floor);
tr.Commit();
}
catch
{
tr.RollBack();
}
}
}
}
trg.Assimilate();
}
return Result.Succeeded;
}
private void Dialogboxshower(object sender, DialogBoxShowingEventArgs e)
{
string s = e.DialogId.ToString();
if (e.DialogId.Equals("Dialog_Revit_DocWarnDialog"))
{
e.OverrideResult((int)TaskDialogResult.CommandLink1);
}
}
}
}
Now, this is working fine, however, theres a nasty "regen flicker" each time, see attached GIF. Ive tried getting at it as a TaskDialog and MessageDialog, both return null. FailureProcessor registers it, but FailuresAccessor.GetFailureMessages() returns empty, so nothing more i could do with that. Could be with how im structuring the nested transactions/for loops? Thoughts?
Solved! Go to Solution.