1

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)
PawelKinczyk
  • 91
  • 10

1 Answers1

2

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
Jan Buijs
  • 98
  • 1
  • 6
  • This is the answer! But when i changed ElementId another problem arose "The document has no open transaction". I workaround this thanks to this post: https://stackoverflow.com/questions/31428726/revit-modifying-is-forbidden-because-the-document-has-no-open-transaction – PawelKinczyk Oct 10 '22 at 18:07