Message 1 of 3
change Parameter values from ModalDialog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I've got a Modal Dialog (instance: thisForm), with references to Document and FamilyManager, which gets started from the Execute method using
thisForm.ShowDialog().
The Parameter values can be updated successfully in the Dialog, but the redraw method fails. It only redraws once the Dialog is closed.
I assume it is the call familyDoc.ReloadLatest(rlo); which closes the Dialog?
I would like to refresh the document leaving the Dialog open.
if (null != familyDoc) { FamilyManager familyManager = familyDoc.FamilyManager; using (frmObjStyles thisForm = new frmObjStyles(pathToFamilyDoc, ref doc, ref familyDoc, ref familyManager, ref opt)) { thisForm.ShowDialog(); if (thisForm.DialogResult == System.Windows.Forms.DialogResult.Cancel) { return Result.Cancelled; } else if (thisForm.DialogResult == System.Windows.Forms.DialogResult.OK) { Class2 c2_ = frmObjStyles.c2 as Class2; using(Transaction trans4 = new Transaction(familyDoc, "Pick a group")) { trans4.Start(); FamilyParameter familyParam = familyManager.get_Parameter("HT_INSIDE_RADIUS_COMPONENT"); if (null != familyParam) familyManager.SetValueString(familyParam, c2_.HT_INSIDE_RADIUS_COMPONENT); familyParam = familyManager.get_Parameter("HT_THICKNESS_COMPONENT"); if (null != familyParam) familyManager.SetValueString(familyParam, c2_.HT_THICKNESS_COMPONENT); familyParam = familyManager.get_Parameter("HT_WIDTH_NOMINAL_COMPONENT"); if (null != familyParam) familyManager.SetValueString(familyParam, c2_.HT_WIDTH_NOMINAL_COMPONENT); trans4.Commit(); } f2 = familyDoc.LoadFamily(doc, opt); SaveAsOptions options = new SaveAsOptions(); options.OverwriteExistingFile = true; options.SetWorksharingOptions(null); familyDoc.SaveAs(pathToFamilyDoc, options); ReloadLatestOptions rlo = new ReloadLatestOptions(); familyDoc.ReloadLatest(rlo); } } }
In the Form class used for the Dialog, the changes are thus captured in a TextChanged Handler:
private void HT_WIDTH_NOMINAL_COMPONENT_TextChanged(object sender, EventArgs e) { if (!init) { //c2.HT_WIDTH_NOMINAL_COMPONENT = HT_WIDTH_NOMINAL_COMPONENT.Text; using(Transaction trans4 = new Transaction(familyDoc, "Pick a group")) { trans4.Start(); System.Windows.Forms.TextBox box = sender as System.Windows.Forms.TextBox; FamilyParameter familyParam = familymanager.get_Parameter(box.Name); if (null != familyParam) familymanager.SetValueString(familyParam, box.Text); trans4.Commit(); } ReloadLatestOptions rlo = new ReloadLatestOptions(); familyDoc.ReloadLatest(rlo); } }