public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { PlunkOClass plunkThis = new PlunkOClass(commandData.Application); string pName = "TCOM - INSTANCE"; BuiltInCategory _bicItemBeingTagged = BuiltInCategory.OST_CommunicationDevices; BuiltInCategory _bicTagBeing = BuiltInCategory.OST_CommunicationDeviceTags; plunkThis.MatchParamenterValue(pName, _bicItemBeingTagged, _bicTagBeing); return(Result.Succeeded); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { Document _doc = commandData.Application.ActiveUIDocument.Document; PlunkOClass plunkThis = new PlunkOClass(commandData.Application); string wsName = "MECH HVAC"; string FamilyTagName = "M_DEVICE_BAS_TAG_SYM"; string FamilyTagNameSymb = "M-DATA-SENSOR"; BuiltInCategory bicItemBeingTagged = BuiltInCategory.OST_DataDevices; BuiltInCategory bicTagBeing = BuiltInCategory.OST_DataDeviceTags; bool oneShot = true; bool hasLeader = true; Element elemTagged = null; string cmdPurpose = "Change To Offset Data"; Result result; try { // first pass result = plunkThis.TwoPickTag(wsName, FamilyTagName, FamilyTagNameSymb, bicItemBeingTagged, bicTagBeing, hasLeader, oneShot, ref elemTagged, cmdPurpose); using (Transaction tp = new Transaction(_doc, "PlunkOMatic:SetParam")) { tp.Start(); // try to uncheck the show sym yes/no is 1/0 Parameter parForVis = elemTagged.LookupParameter("SHOW SYM"); if (null != parForVis) { parForVis.Set(0); } tp.Commit(); } // second pass if (elemTagged != null) { FamilyTagName = "M_EQIP_BAS_SENSOR_TAG"; FamilyTagNameSymb = "TAG NUMBER ONLY"; bicTagBeing = BuiltInCategory.OST_MechanicalEquipmentTags; bicItemBeingTagged = BuiltInCategory.OST_MechanicalEquipment; hasLeader = false; elemTagged = null; cmdPurpose = "Sensor Data"; result = plunkThis.TwoPickTag(wsName, FamilyTagName, FamilyTagNameSymb, bicItemBeingTagged, bicTagBeing, hasLeader, oneShot, ref elemTagged, cmdPurpose); } } catch (Exception) { //throw; } 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; IWin32Window _revit_window; _revit_window = new JtWindowHandle(ComponentManager.ApplicationWindow); IntPtr revWinIntPtr = ComponentManager.ApplicationWindow; PlunkOClass plunkThis = new PlunkOClass(commandData.Application); string _FamilyTagName = "LDT_SWITCH_UNIVERSAL_NEW"; string _FamilyTagSymbName = "SWITCH-TYPE-CONTROL"; string tagContext = "SW"; string tagPref = "PreferedSWTag"; PlunkOClass.ChangeToSavedFamTypePairing(tagPref, ref _FamilyTagName, ref _FamilyTagSymbName); Properties.Settings.Default.LastContextMode = tagContext; Properties.Settings.Default.Save(); BuiltInCategory _bicItemBeingTagged = BuiltInCategory.OST_LightingFixtures; BuiltInCategory _bicTagBeing = BuiltInCategory.OST_LightingDeviceTags; // Check if task is applicable in this view type if (plunkThis.NotInThisView()) { return(Result.Succeeded); } // first check if families are good EnsureTagFamiliesAreLoaded(_doc); plunkThis.TagThisLightSwitchFamilyWithThisTag(_FamilyTagName, // tag family name _FamilyTagSymbName, // tag family symbol name (Type) _bicTagBeing, // builtincategory of the tag _bicItemBeingTagged, // builtincategory of what gets tagged tagPref, // settings name for fam/type pairing to use tagContext); 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); BuiltInCategory _bicItemBeingRot = BuiltInCategory.OST_LightingFixtures; plunkThis.TwoPickAimRotateOne(_bicItemBeingRot); return(Result.Succeeded); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { PlunkOClass plunkThis = new PlunkOClass(commandData.Application); string wsName = "MECH HVAC"; string FamilyTagName = "T-COMM TAG - INSTANCE"; string FamilyTagSymbName = "T-COMM INSTANCE"; bool hasLeader = false; bool oneShot = false; BuiltInCategory bicItemBeingTagged = BuiltInCategory.OST_CommunicationDevices; BuiltInCategory bicTagBeing = BuiltInCategory.OST_CommunicationDeviceTags; Element elemTagged = null; plunkThis.TwoPickTag(wsName, FamilyTagName, FamilyTagSymbName, bicItemBeingTagged, bicTagBeing, hasLeader, oneShot, ref elemTagged); 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); BuiltInCategory _bicItemBeingRot = BuiltInCategory.OST_LightingFixtures; List <ElementId> _selIds; plunkThis.MatchRotationMany(_bicItemBeingRot, out _selIds); // _uidoc.Selection.SetElementIds(_selIds); 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); BuiltInCategory _bicItemDesired = BuiltInCategory.OST_DuctTerminal; List <ElementId> _selIds; plunkThis.PickTheseBicsOnly(_bicItemDesired, out _selIds); _uidoc.Selection.SetElementIds(_selIds); return(Result.Succeeded); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { PlunkOClass plunkThis = new PlunkOClass(commandData.Application); string wsName = "MECH HVAC"; string FamilyTagName = "M_EQIP_BAS_SENSOR_TAG"; string FamilyTagNameSymb = "TAG NUMBER ONLY"; bool hasLeader = false; bool oneShot = false; BuiltInCategory bicTagBeing = BuiltInCategory.OST_MechanicalEquipmentTags; BuiltInCategory bicItemBeingTagged = BuiltInCategory.OST_MechanicalEquipment; Element elemTagged = null; string cmdPurpose = "Sensor Data"; Result res = plunkThis.TwoPickTag(wsName, FamilyTagName, FamilyTagNameSymb, bicItemBeingTagged, bicTagBeing, hasLeader, oneShot, ref elemTagged, cmdPurpose); return(Result.Succeeded); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { PlunkOClass plunkThis = new PlunkOClass(commandData.Application); string wsName = "TCOM"; string FamilyName = "T-COM DROP-WTA"; string FamilySymbolName = "DROP"; string pName = "TCOM - INSTANCE"; string pNameVal = "AP"; string FamilyTagName = "T-COMM TAG - INSTANCE"; string FamilyTagNameSymb = "T-COMM INSTANCE"; bool oneShot = false; bool hasLeader = false; BuiltInCategory bicTagBeing = BuiltInCategory.OST_CommunicationDeviceTags; BuiltInCategory bicFamily = BuiltInCategory.OST_CommunicationDevices; Element elemPlunked; plunkThis.PlunkThisFamilyWithThisTagWithThisParameterSet(FamilyName, FamilySymbolName, pName, pNameVal, wsName, FamilyTagName, FamilyTagNameSymb, bicTagBeing, bicFamily, out elemPlunked, oneShot, hasLeader); 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); List <ElementId> selIds; selIds = plunkThis.notTaggedLights(); if (selIds != null) { uidoc.Selection.SetElementIds(selIds); } 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) { 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) { 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); }
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { UIDocument uiDoc = commandData.Application.ActiveUIDocument; Document doc = uiDoc.Document; Selection sel = uiDoc.Selection; List <ElementId> selIds = new List <ElementId>(); Room thisPickRm = null; string pNamePWR = "INPUT POWER"; PlunkOClass plunkThis = new PlunkOClass(commandData.Application); if (plunkThis.NotInThisView()) { return(Result.Succeeded); } // phase basis is the phase on which element status is determined for inclusion Phase phsBasis = FamilyUtils.GetDesiredPhaseBasis(doc); FormMsgWPF thisReport = new FormMsgWPF(); string bot = "( ESC key cancels )"; string purpose = "Room Lighting - Phase Basis: " + phsBasis.Name; bool stay = true; bool doWeSelect = false; try { while (stay) { RoomSelectionFilter cf = new RoomSelectionFilter(); Reference pickedRoomReference = sel.PickObject(ObjectType.LinkedElement, cf, "Selecting Rooms Only"); if (pickedRoomReference == 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(pickedRoomReference) as RevitLinkInstance; Document linkedDoc = linkInstance.GetLinkDocument(); Element firstRoomElement = linkedDoc.GetElement(pickedRoomReference.LinkedElementId); string selRmName = ""; string selLV = ""; string sePhsCreated = ""; // string daPhsDemo = ""; string selRmNumber = ""; double selRmArea = 0.0; switch (firstRoomElement.GetType().ToString()) { case "Autodesk.Revit.DB.Architecture.Room": thisPickRm = firstRoomElement as Room; if (thisPickRm != null) { selRmName = thisPickRm.Name.ToString(); selRmNumber = thisPickRm.Number.ToString(); Phase phCR = linkedDoc.GetElement(thisPickRm.CreatedPhaseId) as Phase; if (phCR != null) { sePhsCreated = phCR.ToString(); } Level itsLevelRm = thisPickRm.Level; if (itsLevelRm != null) { selLV = itsLevelRm.Name.ToString(); selRmArea = thisPickRm.Area; //selIds.Add(thisPickRm.Id); // does not work. A known Revit fact, cannot highlight linked elements } } break; default: break; } string msgMain = firstRoomElement.Name; msgMain = msgMain + "\n" + "Rm Numb.: " + selRmNumber + "\n" + "At level: " + selLV ; // Get all LightingFixtures in the current room BuiltInCategory bic = BuiltInCategory.OST_LightingFixtures; List <FamilyInstance> famInstances = FamilyUtils.FamilyInstanceCategoryInThisRoom(thisPickRm, bic, doc, phsBasis); Dictionary <string, int> dicFamInstances = new Dictionary <string, int>(); Dictionary <string, double> dicLightFixTypeIP = new Dictionary <string, double>(); if (famInstances != null) { if (doWeSelect) { selIds.Clear(); } foreach (FamilyInstance fi in famInstances) { string fiNamePair = fi.Symbol.FamilyName + " | " + fi.Symbol.Name; //msg = msg + "\n" + fiNamePair; int qty; if (dicFamInstances.TryGetValue(fiNamePair, out qty)) { dicFamInstances[fiNamePair] = qty + 1; } else { dicFamInstances.Add(fiNamePair, 1); Parameter pPwr = fi.Symbol.LookupParameter(pNamePWR); if (pPwr != null) { double convVal = FamilyUtils.ConvertParmValueFromRaw(pPwr.AsDouble()); dicLightFixTypeIP.Add(fiNamePair, convVal); //System.Windows.Forms.MessageBox.Show(fi.Symbol.Name + " " + convVal.ToString()); } } if (doWeSelect) { selIds.Add(fi.Id); } } } string msgDetail = ""; double totRoomLWatts = 0.0; foreach (var item in dicFamInstances) { string itemName = item.Key; int itemCount = item.Value; double itemWatts; if (dicLightFixTypeIP.TryGetValue(item.Key, out itemWatts)) { double totalWattsForItem = itemWatts * Convert.ToDouble(itemCount); totRoomLWatts = totRoomLWatts + totalWattsForItem; msgDetail = msgDetail + "\n" + itemName + " cnt " + itemCount.ToString() + " @ " + itemWatts.ToString("0.00") + " for " + totalWattsForItem.ToString("0.0 w"); } else { /// item key not in dictionary! } } double lightFixPWRDensity = totRoomLWatts / selRmArea; msgMain = msgMain + "\n" + "Rm Area: " + selRmArea.ToString("0.00 sf") + " L Pwr. Density: " + lightFixPWRDensity.ToString("0.00 w/sf") + " Tot: " + totRoomLWatts.ToString("0.00 w") + "\n" + msgDetail; thisReport.SetMsg(msgMain, purpose, bot, true); thisReport.Show(); } } catch (Autodesk.Revit.Exceptions.OperationCanceledException) { //TaskDialog.Show("Cancelled", "User cancelled"); stay = false; thisReport.Close(); uiDoc.Selection.SetElementIds(selIds); return(Result.Cancelled); } //Catch other errors catch (Exception ex) { thisReport.Close(); FamilyUtils.SayMsg("Error At RoomLightingReporter", ex.Message); return(Result.Failed); } if (doWeSelect) { uiDoc.Selection.SetElementIds(selIds); } return(Result.Succeeded); }