Message 1 of 2
cannot update parameter value

Not applicable
05-02-2019
07:57 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I tried to update a shared parameter's value using Set() method in my Command. I get the Parameter through its name and set a new value, it should seem very simple but the modification never displays in the property explorer and no error or exception thrown, I've no idea whether the value is changed. I googled a lot and found nothing fix my problem. What I can ensure is:
I set the Transaction Mode to TransactionMode.Automatic
The Document and the Parameter are not read-only when the method executed.
Here's my code snippet, could anyone tell me what's wrong in my code or give me suggestions? Thanks.
private void OnSave() { if (!CanSave()) { return; } Saved = false; foreach (var id in EditElmentIds) { var element = _doc.GetElement(id); foreach (var item in ChangedItems) { var propertyName = CommonData.CodeParamsDic.FirstOrDefault(t => t.Key == item.Key.ToString()).Value; var param = element.get_parameterByName(propertyName); param?.Set(item.Value); } } MessageBox.Show("Completed!"); EditElmentIds.Clear(); ChangedItems.Clear(); }