public static bool Recognization(Ceiling ceiling) { _ceiling = ceiling; _area = ceiling.get_Parameter(BuiltInParameter.HOST_AREA_COMPUTED).AsDouble(); _level = _doc.GetElement(ceiling.get_Parameter(BuiltInParameter.LEVEL_PARAM).AsElementId()) as Level; _offset = ceiling.get_Parameter(BuiltInParameter.CEILING_HEIGHTABOVELEVEL_PARAM).AsDouble(); bool isFound; _floor = _myLevel.GetFloor(out isFound, _level, _offset) - 1; if (_floor == MyLevel.GetLevelNum() || _floor == -1) { _abandonWriter.WriteAbandonment(ceiling, AbandonmentTable.LevelNotFound); return(false); } return(true); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { UIDocument uiDoc = commandData.Application.ActiveUIDocument; Document doc = uiDoc.Document; Selection sel = uiDoc.Selection; try { bool stay = true; while (stay) { CeilingSelectionFilter cf = new CeilingSelectionFilter(); /// Unable to pick either an active file ceiling and linked file ceiling with PickObject Reference pickedCeilingRef = sel.PickObject(ObjectType.LinkedElement, cf, "Selecting Linked Ceilings Only"); //#region Dealing with non linked picks //Reference pickedCeilingRefNL = sel.PickObject(ObjectType.Element, cf, "Selecting Nonlinked Ceilings Only"); //Element firstCeilingElement = doc.GetElement(pickedCeilingRefNL.ElementId); //#endregion #region Dealing with Linked picks if (pickedCeilingRef == null) { return(Result.Failed); } // we need to get the linked document and then get the element that was picked from the LinkedElementId RevitLinkInstance linkInstance = doc.GetElement(pickedCeilingRef) as RevitLinkInstance; Document linkedDoc = linkInstance.GetLinkDocument(); Element firstCeilingElement = linkedDoc.GetElement(pickedCeilingRef.LinkedElementId); #endregion Ceiling thisPick = firstCeilingElement as Ceiling; Parameter daHTparam = thisPick.get_Parameter(BuiltInParameter.CEILING_HEIGHTABOVELEVEL_PARAM); string daHT = daHTparam.AsValueString(); Parameter itsLevel = thisPick.get_Parameter(BuiltInParameter.LEVEL_PARAM); string daLV = itsLevel.AsValueString(); Parameter whenCreated = thisPick.get_Parameter(BuiltInParameter.PHASE_CREATED); string daPhsCreated = whenCreated.AsValueString(); Parameter whenDemo = thisPick.get_Parameter(BuiltInParameter.PHASE_DEMOLISHED); string daPhsDemo = whenCreated.AsValueString(); TaskDialog thisDialog = new TaskDialog("Ceiling Pick-O-Matic"); thisDialog.TitleAutoPrefix = false; thisDialog.MainIcon = TaskDialogIcon.TaskDialogIconNone; thisDialog.CommonButtons = TaskDialogCommonButtons.Close | TaskDialogCommonButtons.Retry; thisDialog.DefaultButton = TaskDialogResult.Retry; thisDialog.FooterText = "Hitting Escape allows picking again."; //TaskDialog.Show("Ceiling Picker Says", // firstCeilingElement.Category.Name + "\n" + firstCeilingElement.Name + "\n" + // daHT); string msg = firstCeilingElement.Name + "\n" + daHT + " from " + daLV; msg = msg + "\n" + daPhsCreated + " that is " + daPhsDemo; thisDialog.MainInstruction = msg; thisDialog.MainContent = ""; TaskDialogResult tResult = thisDialog.Show(); if (TaskDialogResult.Close == tResult) { stay = false; } } return(Result.Succeeded); } catch (Autodesk.Revit.Exceptions.OperationCanceledException) { //TaskDialog.Show("Cancelled", "User cancelled"); return(Result.Cancelled); } //Catch other errors catch (Exception ex) { TaskDialog.Show("Error", ex.Message); return(Result.Failed); } }