public AreaProperties(AreaProperties ap) { this.AreaElement = ap.AreaElement; this.AreaDocument = ap.AreaDocument; this.AreaElementId = ap.AreaElementId; this.AreaId = ap.AreaId; this.AreaUniqueId = ap.AreaUniqueId; this.AreaName = ap.AreaName; this.AreaNumber = ap.AreaNumber; this.AreaTypeName = ap.AreaTypeName; this.UserHeight = ap.UserHeight; this.LevelId = ap.LevelId; this.LevelName = ap.LevelName; this.AreaDesignOption = ap.AreaDesignOption; this.AreaFace = ap.AreaFace; this.AreaProfile = ap.AreaProfile; this.AreaCenterPoint = ap.AreaCenterPoint; this.Linked3dMass = ap.Linked3dMass; this.Linked2dMass = ap.Linked2dMass; this.Linked3d = ap.Linked3d; this.Linked2d = ap.Linked2d; this.ModifiedHost = ap.ModifiedHost; this.IsSelected = ap.IsSelected; this.ToolTip = ap.ToolTip; }
private void CollectAreas() { try { progressForm = new Form_ProgressBar(); progressForm.LabelText = "Collecting Information from the Revit Project.."; progressForm.LabelCount = collectedAreas.Count + " areas found"; progressForm.Show(); progressForm.MaxValue = collectedAreas.Count; progressForm.Refresh(); foreach (Area area in collectedAreas) { progressForm.PerformStep(); AreaProperties ap = new AreaProperties(doc, area); if (!areaDictionary.ContainsKey(ap.ID) && !ap.CurveArrArray.IsEmpty) { areaDictionary.Add(ap.ID, ap); if (!areaTypeNames.Contains(ap.AreaType)) { areaTypeNames.Add(ap.AreaType); } } } } catch (Exception ex) { MessageBox.Show("Failed to collect Areas data. \n" + ex.Message, "Form_AreaMass:CollectAreas", MessageBoxButtons.OK, MessageBoxIcon.Warning); progressForm.Close(); } }
public static bool CreateAreaSolid(Document doc, AreaProperties ap, out MassProperties createdMass) { bool created = false; createdMass = null; try { string appGuid = doc.Application.ActiveAddInId.GetGUID().ToString(); if (null != ap.Linked3dMass) { //delete existing mass first MassProperties existingMass = ap.Linked3dMass; doc.Delete(new ElementId(existingMass.MassId)); } IList <GeometryObject> areaGeometries = new List <GeometryObject>(); if (ap.AreaProfile.Count > 0) { XYZ extrusionDir = new XYZ(0, 0, 1); Solid areaSolid = GeometryCreationUtilities.CreateExtrusionGeometry(ap.AreaProfile, extrusionDir, ap.UserHeight); if (null != areaSolid) { areaGeometries.Add(areaSolid); } } #if RELEASE2015 || RELEASE2016 DirectShape createdShape = DirectShape.CreateElement(doc, new ElementId(massCategory), appGuid, ap.AreaId.ToString()); #else DirectShape createdShape = DirectShape.CreateElement(doc, new ElementId(massCategory)); createdShape.ApplicationId = appGuid; createdShape.ApplicationDataId = ap.AreaId.ToString(); #endif #if RELEASE2016 DirectShapeOptions options = createdShape.GetOptions(); options.ReferencingOption = DirectShapeReferencingOption.Referenceable; createdShape.SetOptions(options); #endif createdShape.SetShape(areaGeometries); createdShape.SetName(ap.AreaName); Element massElement = doc.GetElement(createdShape.Id); if (null != massElement) { createdMass = new MassProperties(massElement); createdMass.SetHostInfo(ap.AreaUniqueId, SourceType.Areas, ap.AreaCenterPoint, ap.UserHeight); bool stored = MassDataStorageUtil.SetLinkedHostInfo(massElement, SourceType.Areas.ToString(), ap.AreaUniqueId, ap.AreaCenterPoint, ap.UserHeight); created = true; } } catch (Exception ex) { MessageBox.Show("Failed to create area solid.\n" + ex.Message, "Create Area Solid", MessageBoxButtons.OK, MessageBoxIcon.Warning); } return(created); }
private void menuViewElement_Click(object sender, EventArgs e) { using (Transaction trans = new Transaction(doc)) { trans.Start("Show Elements"); try { UIDocument uidoc = m_app.ActiveUIDocument; List <ElementId> elementIds = new List <ElementId>(); #if RELEASE2013 || RELEASE2014 SelElementSet newSelection = SelElementSet.Create(); foreach (DataGridViewRow row in dataGridViewArea.SelectedRows) { if (null != row.Tag) { AreaProperties ap = row.Tag as AreaProperties; ElementId elementId = new ElementId(ap.ID); Element element = doc.GetElement(elementId); if (null != element) { newSelection.Add(element); elementIds.Add(elementId); } } } uidoc.ShowElements(elementIds); uidoc.Selection.Elements = newSelection; #elif RELEASE2015 || RELEASE2016 Selection selection = uidoc.Selection; foreach (DataGridViewRow row in dataGridViewArea.SelectedRows) { if (null != row.Tag) { AreaProperties ap = row.Tag as AreaProperties; ElementId elementId = new ElementId(ap.ID); if (elementId != ElementId.InvalidElementId) { elementIds.Add(elementId); } } } uidoc.ShowElements(elementIds); selection.SetElementIds(elementIds); #endif trans.Commit(); } catch (Exception ex) { MessageBox.Show("Failed to view elements.\n" + ex.Message, "Form_AreaMass: menuViewElement_Click", MessageBoxButtons.OK, MessageBoxIcon.Warning); trans.RollBack(); } } }
private void SaveHeightValues() { try { foreach (DataGridViewRow row in dataGridViewArea.Rows) { if (null != row.Tag && null != row.Cells[6].Value) { AreaProperties ap = row.Tag as AreaProperties; ap.Height = Convert.ToDouble(row.Cells[6].Value); } } } catch (Exception ex) { MessageBox.Show("Failed to save height values.\n" + ex.Message, "Form_AreaMass:SaveHeightValues", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private bool CreateExtrusion(Document fdoc, AreaProperties ap) { bool result = false; try { // make sure we have a family document if (true == fdoc.IsFamilyDocument) { Plane plane = fdoc.Application.Create.NewPlane(XYZ.BasisZ, new XYZ(0, 0, 0)); #if RELEASE2013 SketchPlane skPlane = fdoc.FamilyCreate.NewSketchPlane(plane); #elif RELEASE2014 || RELEASE2015 || RELEASE2016 SketchPlane skPlane = SketchPlane.Create(fdoc, plane); #endif double maxCircum = 0;//to find out the largest outer loop. List <ReferenceArray> profiles = new List <ReferenceArray>(); foreach (CurveArray curveArray in ap.CurveArrArray) { List <XYZ> pointList = new List <XYZ>(); ReferenceArray refArray = new ReferenceArray(); double circumference = 0; foreach (Curve curve in curveArray) { circumference += curve.ApproximateLength; int pointCount = curve.Tessellate().Count; if (pointCount > 2)//edge from a circular face { IList <XYZ> tPoints = curve.Tessellate(); tPoints.RemoveAt(tPoints.Count - 1); foreach (XYZ point in tPoints) { XYZ tempPoint = new XYZ(point.X, point.Y, 0); pointList.Add(tempPoint); } } else if (pointCount == 2) { #if RELEASE2013 XYZ pt = curve.get_EndPoint(0); #elif RELEASE2014 || RELEASE2015 || RELEASE2016 XYZ pt = curve.GetEndPoint(0); #endif XYZ tempPoint = new XYZ(pt.X, pt.Y, 0); if (pointList.Count == 0) { pointList.Add(tempPoint); } if (pointList.Count > 0 && pointList[pointList.Count - 1].DistanceTo(tempPoint) > 0.0026)//revit tolerance will be 1/32" { pointList.Add(tempPoint); } } } if (maxCircum == 0) { maxCircum = circumference; } else if (maxCircum < circumference) { maxCircum = circumference; } int num = pointList.Count; if (num > 2) { Curve newCurve = null; for (int i = 0; i < pointList.Count; i++) { if (i == num - 1) { #if RELEASE2013 newCurve = fdoc.Application.Create.NewLineBound(pointList[i], pointList[0]); #elif RELEASE2014 || RELEASE2015 || RELEASE2016 newCurve = Autodesk.Revit.DB.Line.CreateBound(pointList[i], pointList[0]); #endif } else { #if RELEASE2013 newCurve = fdoc.Application.Create.NewLineBound(pointList[i], pointList[i + 1]); #elif RELEASE2014 || RELEASE2015 || RELEASE2016 newCurve = Autodesk.Revit.DB.Line.CreateBound(pointList[i], pointList[i + 1]); #endif } ModelCurve modelcurve = fdoc.FamilyCreate.NewModelCurve(newCurve, skPlane); refArray.Append(modelcurve.GeometryCurve.Reference); } //first index of profile list will be the outer loop if (maxCircum == circumference) { profiles.Insert(0, refArray); } else { profiles.Add(refArray); } } } if (profiles.Count > 0) { XYZ direction = new XYZ(0, 0, ap.Height); FamilyParameter fparam = fdoc.FamilyManager.get_Parameter("Height"); fdoc.FamilyManager.Set(fparam, ap.Height); for (int i = 0; i < profiles.Count; i++) { Autodesk.Revit.DB.Form solidForm = fdoc.FamilyCreate.NewExtrusionForm(true, profiles[i], direction); CreateHeightLabel(fdoc, solidForm); if (i > 0) { Parameter param = solidForm.get_Parameter(BuiltInParameter.ELEMENT_IS_CUTTING); param.Set(1); //void form } } } result = true; } else { result = false; throw new Exception("Please open a Family document before invoking this command."); } } catch (Exception ex) { MessageBox.Show("Failed to create extrusion.\n" + ex.Message, "MassCreator: CreateExtrusion", MessageBoxButtons.OK, MessageBoxIcon.Warning); result = false; } return(result); }
public FamilyInstance CreateFamily(AreaProperties ap) { FamilyInstance familyInstance = null; try { string currentAssembly = System.Reflection.Assembly.GetAssembly(this.GetType()).Location; string massTemplate = Path.GetDirectoryName(currentAssembly) + "/Resources/Mass.rfa"; Document familyDoc = null; using (Transaction trans = new Transaction(doc)) { trans.Start("Open Document"); familyDoc = m_app.OpenDocumentFile(massTemplate); trans.Commit(); } if (null != familyDoc) { bool createdParam = false; using (Transaction trans = new Transaction(familyDoc)) { FailureHandlingOptions failureHandlingOptions = trans.GetFailureHandlingOptions(); FailureHandler failureHandler = new FailureHandler(); failureHandlingOptions.SetFailuresPreprocessor(failureHandler); failureHandlingOptions.SetClearAfterRollback(true); trans.SetFailureHandlingOptions(failureHandlingOptions); trans.Start("Create Extrusion"); try { FamilyType newFamilyType = familyDoc.FamilyManager.NewType(ap.Name); bool createdMass = CreateExtrusion(familyDoc, ap); Dictionary <string, Parameter> parameters = new Dictionary <string, Parameter>(); parameters = ap.Parameters; if (createdMass) { createdParam = CreateNewParameters(familyDoc, parameters); } if (failureHandler.FailureMessageInfoList.Count > 0) { failureMessage.AppendLine("[" + ap.ID + ": " + ap.Name + "] :" + failureHandler.FailureMessageInfoList[0].ErrorMessage); } trans.Commit(); } catch (Exception ex) { MessageBox.Show("Failed to create family.\n" + ex.Message, "MassCreator: CreateFamily", MessageBoxButtons.OK, MessageBoxIcon.Warning); trans.RollBack(); } } if (createdParam) { SaveAsOptions opt = new SaveAsOptions(); opt.OverwriteExistingFile = true; string fileName = Path.Combine(massFolder, ap.ID + ".rfa"); familyDoc.SaveAs(fileName, opt); familyDoc.Close(true); familyInstance = LoadMassFamily(fileName, ap.LevelObj); } } } catch (Exception ex) { MessageBox.Show("Failed to create family.\n" + ex.Message, "MassCreator: CreateFamily", MessageBoxButtons.OK, MessageBoxIcon.Warning); } return(familyInstance); }
private void buttonUpdateParameters_Click(object sender, RoutedEventArgs e) { try { if (massConfig.UpdateType != ParameterUpdateType.None && massConfig.MassParameters.Count > 0) { var areaList = (List <AreaProperties>)dataGridArea.ItemsSource; var selectedAreas = areaList.Where(x => x.IsSelected).ToList(); if (!selectedAreas.Any()) { return; } statusLable.Text = "Updating Parameters ..."; progressBar.Visibility = System.Windows.Visibility.Visible; progressBar.Value = 0; progressBar.Maximum = selectedAreas.Count(); var updatePbDelegate = new UpdateProgressBarDelegate(progressBar.SetValue); using (var tg = new TransactionGroup(doc)) { tg.Start("Update Parameters"); try { double count = 0; foreach (var ap in selectedAreas) { using (var trans = new Transaction(doc)) { trans.Start("Update Parameter"); var options = trans.GetFailureHandlingOptions(); options.SetFailuresPreprocessor(new DuplicateWarningSwallower()); trans.SetFailureHandlingOptions(options); try { var updated = false; if (null != ap.Linked2dMass) { updated = UpdateParameter(ap.AreaElement, ap.Linked2dMass.MassElement); } if (null != ap.Linked3dMass) { updated = UpdateParameter(ap.AreaElement, ap.Linked3dMass.MassElement); } if (updated) { var updatedArea = new AreaProperties(ap) { IsSelected = false }; AreaDictionary.Remove(ap.AreaUniqueId); AreaDictionary.Add(ap.AreaUniqueId, updatedArea); } trans.Commit(); } catch (Exception ex) { Log.AppendLog(LogMessageType.EXCEPTION, ex.Message); trans.RollBack(); } } count++; Dispatcher.Invoke(updatePbDelegate, System.Windows.Threading.DispatcherPriority.Background, ProgressBar.ValueProperty, count); } DisplayAreaInfo(); tg.Assimilate(); } catch (Exception ex) { Log.AppendLog(LogMessageType.EXCEPTION, ex.Message); tg.RollBack(); MessageBox.Show("Failed to update parameters of linked masses.\n" + ex.Message, "Update Parameters", MessageBoxButton.OK, MessageBoxImage.Warning); } } progressBar.Visibility = System.Windows.Visibility.Hidden; statusLable.Text = "Ready"; } else { MessageBox.Show( "Please set the configuration for the parameter mappings.\nGo to the Parameters Settings button for more detail.", "Parameters Settings Missing", MessageBoxButton.OK, MessageBoxImage.Information); } } catch (Exception ex) { Log.AppendLog(LogMessageType.EXCEPTION, ex.Message); MessageBox.Show("Failed to update parameter values.\n" + ex.Message, "Update Parameters", MessageBoxButton.OK, MessageBoxImage.Warning); } }
private void button2DCreate_Click(object sender, RoutedEventArgs e) { try { var areaList = (List <AreaProperties>)dataGridArea.ItemsSource; var selectedAreas = areaList.Where(x => x.IsSelected).ToList(); if (selectedAreas.Any()) { statusLable.Text = "Creating 2D Masses .."; progressBar.Visibility = System.Windows.Visibility.Visible; progressBar.Value = 0; progressBar.Maximum = selectedAreas.Count(); var createdParamMaps = massConfig.UpdateType != ParameterUpdateType.None && massConfig.MassParameters.Count > 0; var updatePbDelegate = new UpdateProgressBarDelegate(progressBar.SetValue); using (var tg = new TransactionGroup(doc)) { tg.Start("Create 2D Masses"); try { double count = 0; foreach (var ap in selectedAreas) { using (var trans = new Transaction(doc)) { trans.Start("Create 2D Mass"); var options = trans.GetFailureHandlingOptions(); options.SetFailuresPreprocessor(new DuplicateWarningSwallower()); trans.SetFailureHandlingOptions(options); try { if (MassCreator.CreateAreaFace(doc, ap, out var createdMass)) { if (AreaDictionary.ContainsKey(ap.AreaUniqueId)) { var updatedArea = new AreaProperties(ap) { IsSelected = false, Linked2d = true, Linked2dMass = createdMass, ModifiedHost = false }; if (updatedArea.Linked3d && null != updatedArea.Linked3dMass) { updatedArea.ToolTip = "Mass 3D Id: " + updatedArea.Linked3dMass.MassId; updatedArea.ToolTip += "\nMass 2D Id: " + updatedArea.Linked2dMass.MassId; } else { updatedArea.ToolTip = "Mass 2D Id: " + updatedArea.Linked2dMass.MassId; } if (createdParamMaps) { var unused = UpdateParameter(ap.AreaElement, createdMass.MassElement); } AreaDictionary.Remove(ap.AreaUniqueId); AreaDictionary.Add(ap.AreaUniqueId, updatedArea); } } trans.Commit(); } catch (Exception ex) { Log.AppendLog(LogMessageType.EXCEPTION, ex.Message); trans.RollBack(); } } count++; Dispatcher.Invoke(updatePbDelegate, System.Windows.Threading.DispatcherPriority.Background, ProgressBar.ValueProperty, count); } DisplayAreaInfo(); tg.Assimilate(); } catch (Exception ex) { Log.AppendLog(LogMessageType.EXCEPTION, ex.Message); tg.RollBack(); MessageBox.Show("Failed to create 2d masses from the selected areas\n" + ex.Message, "Create 2D Masses from Areas", MessageBoxButton.OK, MessageBoxImage.Warning); } } progressBar.Visibility = System.Windows.Visibility.Hidden; statusLable.Text = "Ready"; } else { MessageBox.Show("Please select areas to update masses.", "Select Areas", MessageBoxButton.OK, MessageBoxImage.Information); } } catch (Exception ex) { Log.AppendLog(LogMessageType.EXCEPTION, ex.Message); MessageBox.Show("Failed to create 2d masses from the selected areas.\n" + ex.Message, "Create 2D Masses from Areas", MessageBoxButton.OK, MessageBoxImage.Warning); } }
private void CollectAreaInfo(List <Area> areaList) { try { foreach (Area area in areaList) { if (area.Area == 0) { continue; } AreaProperties ap = new AreaProperties(area); ap.GetAreaProfile(); StringBuilder strBuilder = new StringBuilder(); var mass3dFound = from mass in massList where mass.HostType == SourceType.Areas && mass.HostUniqueId == ap.AreaUniqueId && mass.MassElementType == MassType.MASS3D select mass; if (mass3dFound.Count() > 0) { MassProperties mp = mass3dFound.First(); ap.Linked3dMass = mp; ap.Linked3d = true; ap.UserHeight = mp.MassHeight; strBuilder.AppendLine("Mass 3D Id: " + mp.MassId); if (null != mp.MassSolid) { if (!ap.AreaCenterPoint.IsAlmostEqualTo(mp.HostSolidCentroid)) { ap.ModifiedHost = true; strBuilder.Append(" (the area has been modified)"); } } } var mass2dFound = from mass in massList where mass.HostType == SourceType.Areas && mass.HostUniqueId == ap.AreaUniqueId && mass.MassElementType == MassType.MASS2D select mass; if (mass2dFound.Count() > 0) { MassProperties mp = mass2dFound.First(); ap.Linked2dMass = mp; ap.Linked2d = true; strBuilder.AppendLine("Mass 2D Id: " + mp.MassId); if (null != mp.MassSolid) { if (!ap.AreaCenterPoint.IsAlmostEqualTo(mp.HostSolidCentroid)) { ap.ModifiedHost = true; strBuilder.Append(" (the area has been modified)"); } } } if (strBuilder.Length > 0) { ap.ToolTip = strBuilder.ToString(); } if (!areaDictionary.ContainsKey(ap.AreaUniqueId)) { areaDictionary.Add(ap.AreaUniqueId, ap); } } } catch (Exception ex) { MessageBox.Show("Failed to collect area Information.\n" + ex.Message, "Collect Areas Information", MessageBoxButton.OK, MessageBoxImage.Warning); } }
private void DisplayAreaData() { try { progressForm.LabelText = "Preparing Components to be Displayed.."; progressForm.CurValue = 1; progressForm.Refresh(); foreach (int areaId in areaDictionary.Keys) { progressForm.PerformStep(); AreaProperties ap = areaDictionary[areaId]; int index = dataGridViewArea.Rows.Add(); DataGridViewRow row = dataGridViewArea.Rows[index]; row.Tag = ap; row.Cells[0].Value = false; row.Cells[1].Value = ap.Number; row.Cells[2].Value = ap.Name; row.Cells[3].Value = ap.Level; row.Cells[4].Value = ap.DesignOption; row.Cells[5].Value = ap.AreaType; row.Cells[6].Value = 10; //default height=10 if (placedAreas.Contains(ap.ID)) { //row.ReadOnly = true; row.Cells[0].Value = false; row.DefaultCellStyle.ForeColor = System.Drawing.Color.Gray; foreach (DataGridViewCell cell in row.Cells) { cell.ToolTipText = ap.ID + ": Mass family is already placed in the project."; } } if (areaDiscrepancy.Contains(ap.ID)) { row.Cells[0].Value = true; row.DefaultCellStyle.ForeColor = System.Drawing.Color.Red; foreach (DataGridViewCell cell in row.Cells) { cell.ToolTipText = ap.ID + ": Area boundary lines have been changed."; } } } if (defDictionary.Count > 0) { string parameters = ""; foreach (string defName in defDictionary.Keys) { parameters += "[" + defName + "] "; } richTextBoxParameters.Text = parameters; } progressForm.Close(); } catch (Exception ex) { MessageBox.Show("Failed to display area data.\n" + ex.Message, "Form_AreaMass:DisplayAreaData", MessageBoxButtons.OK, MessageBoxIcon.Warning); progressForm.Close(); } }
private void bttnCreate_Click(object sender, EventArgs e) { try { List <int> checkedRows = new List <int>(); for (int i = 0; i < dataGridViewArea.Rows.Count; i++) { if (Convert.ToBoolean(dataGridViewArea.Rows[i].Cells[0].Value)) { checkedRows.Add(i); } } if (checkedRows.Count > 0) { double height = 0; if (checkBoxHeight.Checked) { if (!ValidateHeight(out height)) { MessageBox.Show("Please enter a valid area height.", "Area Height Required", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } else if (height == 0) { MessageBox.Show("Please enter a valid area height.", "Area Height Required", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } } massCreator.DefDictionary = defDictionary; SaveHeightValues(); Dictionary <int, AreaProperties> createdAreas = new Dictionary <int, AreaProperties>(); Dictionary <int, MassProperties> placedMasses = new Dictionary <int, MassProperties>(); statusLabel.Text = "Updating Masses . . ."; toolStripProgressBar.Maximum = checkedRows.Count; toolStripProgressBar.Visible = true; StringBuilder resultMessage = new StringBuilder(); foreach (int index in checkedRows) { toolStripProgressBar.PerformStep(); DataGridViewRow row = dataGridViewArea.Rows[index]; if (null != row.Tag) { AreaProperties ap = row.Tag as AreaProperties; MassProperties mp = new MassProperties(); mp.HostElementId = ap.ID; if (placedAreas.Contains(ap.ID)) { FamilyInstance instance = MassUtils.FindMassById(doc, ap.ID); if (null != instance) { mp.MassFamilyInstance = instance; if (!placedMasses.ContainsKey(ap.ID)) { placedMasses.Add(ap.ID, mp); } resultMessage.AppendLine(ap.ID + "\t" + ap.Number + "\t" + ap.Name); } continue; } if (areaDiscrepancy.Contains(ap.ID)) { FamilyInstance instance = MassUtils.FindMassById(doc, ap.ID); if (null != instance) { using (Transaction trans = new Transaction(doc)) { trans.Start("Delete Element"); doc.Delete(instance.Id); trans.Commit(); } } } FamilyInstance familyInstance = massCreator.CreateFamily(ap); if (null != familyInstance) { mp.MassFamilyInstance = familyInstance; if (!placedMasses.ContainsKey(ap.ID)) { placedMasses.Add(ap.ID, mp); } } createdAreas.Add(ap.ID, ap); resultMessage.AppendLine(ap.ID + "\t" + ap.Number + "\t" + ap.Name); } } foreach (int areaId in placedAreas) { FamilyInstance instance = MassUtils.FindMassById(doc, areaId); MassProperties mp = new MassProperties(); if (null != instance) { mp.MassFamilyInstance = instance; if (!placedMasses.ContainsKey(areaId)) { placedMasses.Add(areaId, mp); } } } statusLabel.Text = "Done"; iniDataManager.CreatedAreas = createdAreas; iniDataManager.WriteINI(); if (massCreator.FailureMessage.Length > 0) { DialogResult dr = MessageBox.Show("Errors occured while creating extrusion forms.\n" + massCreator.FailureMessage.ToString(), "Warning Message", MessageBoxButtons.OK, MessageBoxIcon.Warning); if (dr == DialogResult.OK) { using (Transaction trans = new Transaction(doc)) { trans.Start("Set Shared Parameters"); m_app.Application.SharedParametersFilename = originalDefFile; trans.Commit(); } this.Close(); } } else { if (resultMessage.Length > 0) { string header = "Area Masses are sucessfully created. \n[Area ID], [Area Number], [Area Name]\n"; MessageBoxForm messageForm = new MessageBoxForm("Completion Messages", header + resultMessage.ToString(), "", false, false); if (DialogResult.OK == messageForm.ShowDialog()) { using (Transaction trans = new Transaction(doc)) { trans.Start("Set Shared parameters"); m_app.Application.SharedParametersFilename = originalDefFile; trans.Commit(); } this.Close(); } } } } else { MessageBox.Show("Please select at leaset one Area item to proceed.", "Empty Selection", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show("Failed to create mass rooms.\n" + ex.Message, "Form_CreateMass:BttnCreate_Click", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }