It closed my original question. Fairly new to c# & I'm wondering if there is a way to do the following:
string joint = "Press Joint" || "ProPress";
Would I achieve this using a switch statement? I.e. set the string to be empty & programmatically pull a value & switch the case depending on the value? I've created an updater utility to check the models in Revit to enforce minimum pipe length standards. The code is pretty lengthy but hopefully what I pulled out makes sense.
internal class UtilsFabricationPipeLengths
{
public static FailureDefinitionId illegalPipeLengthFailureId;
public static FailureDefinitionId illegalPipeLengthFailureId2;
public static FailureDefinitionId illegalPipeLengthFailureId3;
// public static FailureDefinitionId illegalPipeLengthFailureId4;
public static FailureDefinitionId illegalPipeLengthFailureId5;
public static FailureDefinitionId illegalPipeLengthFailureId6;
public static FailureDefinitionId illegalPipeLengthFailureId7;
public class FabricationPipeLengthsUpdater : IUpdater
{
private readonly UpdaterId fabricationPipeLengthsUpdaterId;
private FabricationDimensionDefinition fabricationDimensionDefinition;
public FabricationPipeLengthsUpdater(AddInId id)
{
fabricationPipeLengthsUpdaterId = new UpdaterId(id, new Guid("B0C85739-93DB-44A6-BC74-92280998063E"));
}
public void Execute(UpdaterData data)
{
try
{
{
string brazed = "Brazed";
string pressJoint = "Press Joint";
string soldered = "Soldered";
string threaded = "Threaded";
string buttWeld = "ButtWeld";
string pexJoint = "Pex Joint";
Document doc = data.GetDocument();
List<ElementId> ids = new List<ElementId>();
ids.AddRange(data.GetAddedElementIds());
ids.AddRange(data.GetModifiedElementIds());
foreach (ElementId id in ids)
{
if (doc.GetElement(id) is FabricationPart fabricationPart)
{
Autodesk.Revit.DB.Parameter lLength = fabricationPart.LookupParameter("Length");
lLength.AsDouble().ToString();
Autodesk.Revit.DB.Parameter fpdsd = fabricationPart.get_Parameter(BuiltInParameter.CURVE_ELEM_LENGTH);
fpdsd.AsDouble().ToString();
//Don't execute if the change was not trigerred by the wanted parameter
if (!data.IsChangeTriggered(id, Element.GetChangeTypeParameter(new ElementId(BuiltInParameter.FABRICATION_PART_LENGTH))))
{
break;
}
if (!fabricationPart.IsValidObject)
continue;
#region Press To Existing Soldered
if ( fabricationPart.ProductInstallType == pressJoint &&
(decimal)lLength.AsDouble() < 0.2239583333m &&
fabricationPart.ProductSizeDescription == "1-1/4" ||
fabricationPart.ProductInstallType == pressJoint &&
(decimal)lLength.AsDouble() < 0.2812500000m &&
fabricationPart.ProductSizeDescription == "1-1/2" ||
fabricationPart.ProductInstallType == pressJoint &&
(decimal)lLength.AsDouble() < 0.3229166667m &&
fabricationPart.ProductSizeDescription == "2")
#endregion
else
{
continue;
}
}
}
}
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
}
public UpdaterId GetUpdaterId()
{
UpdaterId id = fabricationPipeLengthsUpdaterId;
return (id);
}
public ChangePriority GetChangePriority()
{
return ChangePriority.MEPSystems;
}
public string GetUpdaterName()
{
return "Fabrication Pipe Updater";
}
public string GetAdditionalInformation()
{
return "Fabrication Pipe updater example: checks the lenghts of pipe to make sure " +
"all pipes meet minimum pipe length requirements.";
}
}
}
The string value pressJoint can vary with what is being checked between "Press Joint", "ProPress", & "PressFit".