Insulation Tag

Mar 7, 2015

I am not very fond of duct and pipe insulations in Revit. If the concept is very useful, I find difficult to add and edit them. Furthermore, seeing the insulation on every duct and pipe can quickly clutters the view. We want to know how much insulation we have, but we don’t want to see it everywhere.

In a technical drawing, we generally represent insulation only on small parts of the duct, with an annotation, and then infer that the duck is covered everywhere else.

To adapt this method on Revit, I create two detail components, representing the insulation on a round and on a rectangular duct.

This components have a “Width” instance parameter for setting their width regarding the thickness of the insulation.

I also create a small piece of code to instantiate these components on selected ducts and pipes.

The idea is to pick a series of duct and pipe, read their insulation thickness, and add a detail component with the corresponding thickness. Like this, we can control where we want to see an insulation, and improve the overall legibility of the drawing.

This solution allow me to create quickly some annotations to represent the insulation without having to display it everywhere. However, this is more a workaround than a real solution. Nothing here is adaptive, and you have to restart the tool each time you edit or even move your duct.

publicvoidInsulationTag(){UIDocumentuidoc=this.ActiveUIDocument;Documentdoc=uidoc.Document;Referencer=null;//Retrive the two symbolsFamilySymbolrectangularSymbol=null;FamilySymbolroundSymbol=null;ICollection<Element>collection=newFilteredElementCollector(doc).OfClass(typeof(FamilySymbol)).OfCategory(BuiltInCategory.OST_DetailComponents).ToElements();foreach(Elementelementincollection){FamilySymbolcurrent=elementasFamilySymbol;// This NewFamilyInstance overload requires a curve based familyif(current.Family.Name=="DuctInsulationAnnotationRectangular"){rectangularSymbol=current;}elseif(current.Family.Name=="DuctInsulationAnnotationRound"){roundSymbol=current;}}try{while(true){using(Transactiont=newTransaction(doc)){t.Start("Annotate Insulations");r=uidoc.Selection.PickObject(ObjectType.Element,newSelectionFilter(),"Pick a duct");if(r!=null){MEPCurvemepCurve=doc.GetElement(r.ElementId)asMEPCurve;//doc.ActiveView.GetElementOverrides//Get the middle of the ductLocationCurvelocCurve=mepCurve.LocationasLocationCurve;XYZinsertionPoint=locCurve.Curve.Evaluate(0.5,true);//Get the angleXYZvector=locCurve.Curve.GetEndPoint(1)-locCurve.Curve.GetEndPoint(0);doubleangle=newXYZ(1,0,0).AngleTo(vector);//Get the insulationICollection<ElementId>insulationIds=InsulationLiningBase.GetInsulationIds(doc,r.ElementId);if(insulationIds.Count!=0){InsulationLiningBaseinsulation=doc.GetElement(insulationIds.First())asInsulationLiningBase;if(insulation!=null){FamilySymbolsymbol=null;doublewidht;try{widht=insulation.Width;//Select the detail famillysymbol=rectangularSymbol;}catch(Autodesk.Revit.Exceptions.InvalidOperationException){ParameterouterDiameter=mepCurve.get_Parameter(BuiltInParameter.RBS_PIPE_OUTER_DIAMETER);if(outerDiameter!=null){widht=insulation.Thickness*2+outerDiameter.AsDouble();}else{widht=insulation.Diameter;}//Select the detail famillysymbol=roundSymbol;}//Create the annotationFamilyInstanceannotation=doc.Create.NewFamilyInstance(insertionPoint,symbol,doc.ActiveView);//Change the witdhannotation.GetParameters("Width").First().Set(widht);//rotate the componentannotation.Location.Rotate(Line.CreateUnbound(insertionPoint,newXYZ(0,0,1)),-angle);}}}t.Commit();}}}catch(Autodesk.Revit.Exceptions.OperationCanceledException){}}publicclassSelectionFilter:ISelectionFilter{#regionISelectionFilterMemberspublicboolAllowElement(Elementelem){if(elem.Category.Id.IntegerValue==(int)BuiltInCategory.OST_DuctCurves)returntrue;if(elem.Category.Id.IntegerValue==(int)BuiltInCategory.OST_PipeCurves)returntrue;returnfalse;}publicboolAllowReference(Referencerefer,XYZpos){if(refer.ElementReferenceType==ElementReferenceType.REFERENCE_TYPE_NONE)returnfalse;if(refer.ElementReferenceType==ElementReferenceType.REFERENCE_TYPE_SURFACE)returntrue;if(refer.ElementReferenceType==ElementReferenceType.REFERENCE_TYPE_LINEAR)returntrue;returnfalse;}#endregion}