Revit API add insulation error - expected ElementId, got int

408 views Asked by At

I try to write program for add insulation in Revit model. Now i want put only one type of insulation and thicknes (user sets type and insulation → in the future) but i don’t know how to work around the error “expected ElementId, got int”. I tried few codes:

  1. Plumbing.PipeInsulation.Create(doc,i.ElementId,599323,10) #599323 insulation type id, 10 - thicknes
  2. Plumbing.PipeInsulation.Create(doc,i,599323,10)
  3. Plumbing.PipeInsulation.Create(doc,str(i.ElementId),599323,10)

etc. in all ways script doesn’t work because of wrong type of element id input. Thanks for help. My code:

import clr
import sys
import os

from rpw import revit
from Autodesk.Revit.UI.Selection import *
from Autodesk.Revit.DB import *
from pyrevit import DB, forms

doc = revit.doc
uidoc = revit.uidoc

# Pick model elements and add insulation
try:
    with forms.WarningBar(title="Pick elements in model"):
        collector = uidoc.Selection.PickObjects(ObjectType.Element)
        
    for i in collector:
        try:
            
            Plumbing.PipeInsulation.Create(doc,i.ElementId,599323,10) #599323 -insulation type id, 10 - thicknes
        except Exception as e: 
            print(e)
except Exception as e: 
    print(e)
1

There are 1 answers

1
Jan Buijs On BEST ANSWER

It's probably not the second parameter which is wrong, but the third one. You're giving the method 599323 as an integer, while it's expecting an ElementId.

I think something like this should work:

Plumbing.PipeInsulation.Create(doc, i.ElementId, ElementId(599323), 10) #599323 insulation type id, 10 - thicknes