public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication uiapp = commandData.Application; UIDocument _uidoc = uiapp.ActiveUIDocument; Autodesk.Revit.ApplicationServices.Application _app = uiapp.Application; Autodesk.Revit.DB.Document _doc = _uidoc.Document; PlunkOClass plunkThis = new PlunkOClass(commandData.Application); string wsName = "MECH HVAC"; string FamilyName = "M_BAS SENSOR"; string FamilySymbolName = "THERMOSTAT"; string pName = "STAT ZONE NUMBER"; string FamilyTagName = "M_EQIP_BAS_SENSOR_TAG"; string FamilyTagNameSymb = "SENSOR"; bool oneShot = true; bool hasLeader = false; BuiltInCategory bicTagBeing = BuiltInCategory.OST_MechanicalEquipmentTags; BuiltInCategory bicFamily = BuiltInCategory.OST_DataDevices; BuiltInCategory _bicMechItem = BuiltInCategory.OST_MechanicalEquipment; Element elemPlunked; bool keepOnTruckn = true; while (keepOnTruckn) { try { Result result = plunkThis.PlunkThisFamilyType(FamilyName, FamilySymbolName, wsName, bicFamily, out elemPlunked, oneShot); FormMsgWPF formMsg = new FormMsgWPF(); if ((result == Result.Succeeded) & (elemPlunked != null)) { formMsg.Show(); formMsg.SetMsg("Now Select the Mech Unit for this sensor.", "Sensor For MEQ"); Transaction tp = new Transaction(_doc, "PlunkOMatic:OrientGuts "); tp.Start(); plunkThis.OrientTheInsides(elemPlunked); tp.Commit(); ICollection <BuiltInCategory> categories = new[] { _bicMechItem }; ElementFilter myPCatFilter = new ElementMulticategoryFilter(categories); ISelectionFilter myPickFilter = SelFilter.GetElementFilter(myPCatFilter); try { Reference pickedElemRef = _uidoc.Selection.PickObject(ObjectType.Element, myPickFilter, "Select the Mech Unit for this sensor."); Element pickedElem = _doc.GetElement(pickedElemRef.ElementId); formMsg.SetMsg("Now place the unit text at the sensor.", "Sensor For MEQ"); plunkThis.AddThisTag(pickedElem, FamilyTagName, FamilyTagNameSymb, pName, bicTagBeing, hasLeader); formMsg.Close(); } catch (Exception) { formMsg.Close(); keepOnTruckn = false; //throw; } } else { formMsg.Close(); keepOnTruckn = false; } } catch (Autodesk.Revit.Exceptions.OperationCanceledException) { keepOnTruckn = false; // TaskDialog.Show("Where", "here " ); } } return(Result.Succeeded); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication uiapp = commandData.Application; UIDocument _uidoc = uiapp.ActiveUIDocument; Autodesk.Revit.ApplicationServices.Application _app = uiapp.Application; Autodesk.Revit.DB.Document _doc = _uidoc.Document; PlunkOClass plunkThis = new PlunkOClass(commandData.Application); string wsName = "MECH HVAC"; string FamilyName = "M_BAS SENSOR"; string FamilySymbolName = "THERMOSTAT"; string FamilyTagName = "M_EQIP_BAS_SENSOR_TAG"; string FamilyTagNameSymb = "TAG NUMBER ONLY"; string FamilyTagName2 = "M_DEVICE_BAS_TAG_SYM"; string FamilyTagNameSymb2 = "M-DATA-SENSOR"; bool hasLeader = false; bool oneShot = true; BuiltInCategory bicTagBeing = BuiltInCategory.OST_MechanicalEquipmentTags; BuiltInCategory bicTagBeing2 = BuiltInCategory.OST_DataDeviceTags; BuiltInCategory bicFamily = BuiltInCategory.OST_DataDevices; BuiltInCategory bicMechItem = BuiltInCategory.OST_MechanicalEquipment; Element elemPlunked; bool keepOnTruckn = true; while (keepOnTruckn) { try { Result result = plunkThis.PlunkThisFamilyType(FamilyName, FamilySymbolName, wsName, bicFamily, out elemPlunked, oneShot); FormMsgWPF formMsg = new FormMsgWPF(); if ((result == Result.Succeeded) & (elemPlunked != null)) { plunkThis.AddThisTag(elemPlunked, FamilyTagName2, FamilyTagNameSymb2, "Offset Stat", bicTagBeing2, true); formMsg.Show(); formMsg.SetMsg("Now Select the Mech Unit for this sensor.", "Offset Sensor For MEQ"); Transaction tp = new Transaction(_doc, "PlunkOMatic:SymVis"); tp.Start(); Parameter parForVis = elemPlunked.LookupParameter("SHOW SYM"); if (null != parForVis) { parForVis.Set(0); } plunkThis.OrientTheInsides(elemPlunked); // left in in case type is changed later tp.Commit(); ICollection <BuiltInCategory> categories = new[] { bicMechItem }; ElementFilter myPCatFilter = new ElementMulticategoryFilter(categories); ISelectionFilter myPickFilter = SelFilter.GetElementFilter(myPCatFilter); try { Reference pickedElemRef = _uidoc.Selection.PickObject(ObjectType.Element, myPickFilter, "Select the Mech Unit for this sensor."); Element pickedElem = _doc.GetElement(pickedElemRef.ElementId); formMsg.SetMsg("Now place the unit text at the sensor.", "Offset Sensor For MEQ"); plunkThis.AddThisTag(pickedElem, FamilyTagName, FamilyTagNameSymb, "Offset Stat", bicTagBeing, hasLeader); formMsg.Close(); } catch (Exception) { formMsg.Close(); keepOnTruckn = false; //throw; } } else { formMsg.Close(); keepOnTruckn = false; } } catch (Exception) { keepOnTruckn = false; //throw; } } return(Result.Succeeded); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { Autodesk.Revit.DB.Document doc = commandData.Application.ActiveUIDocument.Document; PlunkOClass plunkThis = new PlunkOClass(commandData.Application); string wsName = "ELEC LIGHTING DIAGNOSTIC"; string FamilyName = "OCC-SENSOR-DETECTION-CMR09"; string FamilySymbolName = "DET BLADES ALL"; string pNameOccHeight = "HEIGHT_ABOVE_FLOOR"; bool oneShot = true; BuiltInCategory bicFamily = BuiltInCategory.OST_LightingDevices; if (plunkThis.NotInThisView()) { return(Result.Succeeded); } CheckThisFamilyPairing(doc, typeof(FamilySymbol), FamilyName, FamilySymbolName, bicFamily); Element elemPlunked = null; double optOffset = plunkThis.GetCeilingHeight("OCC Sensor Tool Plunk"); Double pOffSetX = 0.0; Double pOffSetY = 0.0; Double pOffSetZ = 0.0 + optOffset; Units unit = commandData.Application.ActiveUIDocument.Document.GetUnits(); string optMSG = " : will be at " + UnitFormatUtils.Format(unit, UnitType.UT_Length, optOffset, false, false); if (optOffset != 0.0) { plunkThis.PlunkThisFamilyType(FamilyName, FamilySymbolName, wsName, bicFamily, out elemPlunked, oneShot, pOffSetX, pOffSetY, pOffSetZ, optMSG); } /// At this point there may or may not have been an element placed. #region SetParametersSection if (elemPlunked != null) { using (Transaction tp = new Transaction(doc, "PlunkOMatic:SetParam")) { tp.Start(); //TaskDialog.Show(_pName, _pName); Parameter parToSet = null; parToSet = elemPlunked.LookupParameter(pNameOccHeight); string strVal = UnitFormatUtils.Format(unit, UnitType.UT_Length, optOffset, false, false); if (null != parToSet) { parToSet.SetValueString(strVal); // this parameter is distance, therefore valuestring } else { FamilyUtils.SayMsg("Cannot Set Parameter Value: " + strVal, "... because parameter:\n" + pNameOccHeight + "\ndoes not exist in the family:\n" + FamilyName + "\nof Category:\n" + bicFamily.ToString().Replace("OST_", "")); } tp.Commit(); } } #endregion return(Result.Succeeded); }