Preview Wall curve change without committing transaction.

Preview Wall curve change without committing transaction.

Mert_Yacan
Contributor Contributor
345 Views
1 Reply
Message 1 of 2

Preview Wall curve change without committing transaction.

Mert_Yacan
Contributor
Contributor

Hi. What is the best way to preview a change on a 3d view without committing a transaction?

 

I tried using Regenerate() but I faced a bug, When I regenerate I see both the old geometry of the wall and also the new geometry simultaneously:

 

 

UIApplication uiapp = commandData.Application;
Document doc = uiapp.ActiveUIDocument.Document;

ElementId elementid = uiapp.ActiveUIDocument.Selection.PickObject(ObjectType.Element, "Select element or ESC to reset the view").ElementId;
var tempObject = doc.GetElement(elementid);

Wall wall = tempObject as Wall;

MessageBox.Show(wall.Category.Name);
Line l = (wall.Location as LocationCurve).Curve as Line;

MessageBox.Show(l.GetEndPoint(0).ToString() + " " + l.GetEndPoint(1).ToString() + " " + (l.GetEndPoint(1) / 2 + l.GetEndPoint(0) / 2).ToString());

using (Transaction trans = new Transaction(doc))
{
    trans.Start("Changing wall curve.");

    (wall.Location as LocationCurve).Curve =
    Line.CreateBound(new XYZ(10, 10, 0), new XYZ(5, 5, 0));

    doc.Regenerate();

    MessageBox.Show("When this message pops up, I need to see the change");

    trans.RollBack();
}

return Result.Succeeded;

 

 

Mert_Yacan_1-1668846188791.png

 

 

Mert_Yacan_0-1668846140226.png

 

If I comment out these two lines of code then it solves the issue, but this doesn't look stable. I want to know if there is a better way.


 

 

// I need to comment out the code below:
//MessageBox.Show(wall.Category.Name.ToString());
Line l = (wall.Location as LocationCurve).Curve as Line;


//I need to comment out the code below:
//MessageBox.Show(l.GetEndPoint(0).ToString() + " " + l.GetEndPoint(1).ToString() + " " + (l.GetEndPoint(1) / 2 + l.GetEndPoint(0) / 2).ToString());

 

 

Mert_Yacan_2-1668846451874.png

 

0 Likes
Accepted solutions (1)
346 Views
1 Reply
Reply (1)
Message 2 of 2

Mert_Yacan
Contributor
Contributor
Accepted solution

I didn't want to commit the transaction before the user accepted the change since undoing those changes would be challenging. 

I used TransactionGroups to RollBack instead of a transaction. I think it solved my issue, now I can see the changes and still RollBack them in the end.