Pipe and Pipe Fittings Insulation by Size

Hi,

I am trying to add insulation to pipes by size. I have more than two sizes that is why I have problems with the filter. Can Anyone help?

Hello and welcome :wink: be sure you post your image the right way, so we really can see whats goin on…take a look here

Thanks! I hope this image is readable.

not really :wink: for me :wink: try zoom in one node so you can see the name and then export as image from dynamo ui…and if you cant see it yourself, i guess we cant as well :wink: ,)

Another try :slightly_smiling_face:

yeah better :wink: but many things can go wrong :wink: i cant rebuild you graph, so a sample rvt, and a dyn, could help in this case here

Sure, thanks a lot.

Rohrdämmungsscript Kronsrode test2.dyn (159.6 KB)

Sample file.dwg (19.8 KB)

Unfortunately, I cannot upload rvt files as the size is too large.

allright no worries, but i see you do a lot in same graph, right? try do it very simple first and when it works scale it up, and work from there…or simple follow your list backwards until you find the issue and fix it :wink: :wink:

I see a few issues -there’s a lot of repetition and I think the MEPover Element.AddInsulation node only adds insulation - it does not change insulation
Also the way it applies multiple sizes or types may not behave as expected

Here is how I would approach the task using Dynamo’s inbuilt ability to process lists - collect all pipes and fittings, group by system type, then filter for connections and diameter size - then apply insulation (delete if necessary).

Code to apply insulation
IN[0] to be a list of lists with pipes and fittings collected by desired insulation size
IN[1] the PipeInsulationType (can only be this type)
IN[2] the insulation thickness - to have the same number if items as the top list of pipes

import clr

clr.AddReference("RevitServices")
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import *

from System.Collections.Generic import List

doc = DocumentManager.Instance.CurrentDBDocument


def to_list(item):
    if isinstance(item, list):
        return item
    return [item]


def to_internal_units(n, units=None):
    if units is None:
        units = (
            doc
            .GetUnits()
            .GetFormatOptions(SpecTypeId.Length)
            .GetUnitTypeId()
        )
    return UnitUtils.ConvertToInternalUnits(n, units)
    

pipes = to_list(UnwrapElement(IN[0]))
insul_type = ElementId(IN[1].Id)
sizes = [to_internal_units(n) for n in to_list(IN[2])]

assert len(pipes) == len(sizes)

OUT = dict(success=[], failed=[])

TransactionManager.Instance.EnsureInTransaction(doc)
for items, size in zip(pipes, sizes):
    for pipe in items:
        try:
            # Check if already insulated
            insul_ids = Plumbing.PipeInsulation.GetInsulationIds(doc, pipe.Id)
            if insul_ids:
                doc.Delete(List[ElementId](insul_ids))
            
            Plumbing.PipeInsulation.Create(doc, pipe.Id, insul_type, size)
            
            OUT["success"].append(pipe)
        except Exception as e:
            OUT["failed"].append(e.Message)
        
TransactionManager.Instance.TransactionTaskDone()
1 Like

Great, thank you!

I cannot find this node. Can you tell me which package includes this node?

Genius Loci

1 Like