Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi
I'm trying to change parametervalues of the profile of a wallsweep programmatically (the user clicks on a wallsweep, the parameters of the profile are loaded into a form & the user can modify the parameters). Now to change multiple parametervalues of the profile at once I'm using a for loop enclosed in a transaction. The problem is that the transaction does not seem to commit and the for loop does not loop over all values.
I guess it's probably an issue with the transaction?
Thanks in advance 🙂
public void Execute(UIApplication app)
{
string eID = this.savedelementid;//retrieving the unique id saved using another externaleventhandler
Element el = app.ActiveUIDocument.Application.ActiveUIDocument.Document.GetElement(eID); // retrieving the wallsweep element - (works fine)
WallSweep ws;
WallSweepInfo wsi;
List<Parameter> lp;
List<String> ls;
lp = this.SetParameter;// list of parameters of the wall sweep obtained using another externaleventhandler - (works fine)
ls = this.SetValue;// list of parameter values of the wall sweep obtained using another externaleventhandler - (works fine)
if (el is WallSweep)
{
ws = (WallSweep)el;
wsi = (WallSweepInfo)ws.GetWallSweepInfo();
Element wsprofile = app.ActiveUIDocument.Application.ActiveUIDocument.Document.GetElement(wsi.ProfileId); // retrieving the profile elmement of the wall sweep- (works fine)
TaskDialog.Show("melding", wsprofile.Name.ToString()); // prints out the correct name
using (Transaction transaction = new Transaction(app.ActiveUIDocument.Application.ActiveUIDocument.Document))
{
if (transaction.Start("change dimension") == TransactionStatus.Started)
{
for (int i = 0; i < lp.Count; i++)
{
MessageBox.Show(i.ToString()); // only prints out 0 and 1, while lp.Count = 20?
wsprofile.LookupParameter(lp[i].Definition.Name).SetValueString(ls[i]);
}; app.ActiveUIDocument.Application.ActiveUIDocument.Document.Regenerate();
transaction.Commit(); //does not commit the changes
};
}
}
}
}
Solved! Go to Solution.