Message 1 of 7
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I want to propose routes that can connect two conduits together. Each time I proposed a route, I will create conduit and commit the transaction group. When user want to select another route, I want to undo the previous transaction group. That's where the problem occurs when I try to undo the previous transaction.
I have tried with Undo Postable Command, but it only undo the following transaction but not the previous one. (Please correct me if I am wrong with the usage of this Postable Command).
Hope that someone can provide guidance with how to execute undo. Thank you in advance.
Below is my code.
public void GenerateRouting(UIApplication uiApp)
{
Document doc = uiApp.ActiveUIDocument.Document;
if (_routingCounter != 0)
{
RevitCommandId id = RevitCommandId.LookupPostableCommandId(PostableCommand.Undo);
uiApp.PostCommand(id);
}
if (_firstElement != null && _secondElement != null)
{
List<char> sequence;
if (CustomizeRouting)
{
sequence = GetDirectionSequence();
}
else
{
sequence = _directionSequences[_routingCounter];
_routingCounter = (_routingCounter + 1) % _directionSequences.Count();
}
XYZ tempStartPoint = _actualStartPoint;
try
{
TransactionGroup transactionGroup = new TransactionGroup(doc, "Generate Route Transaction Group");
transactionGroup.Start();
using (Transaction st = new Transaction(doc, "Create Conduit"))
{
st.Start();
CreateConduit(doc, sequence, _actualEndPoint, tempStartPoint);
st.Commit();
transactionGroup.Assimilate();
}
}
catch (Exception ex)
{
}
}
}
Solved! Go to Solution.