Change the value of a Build In Parameter in Python

I am trying to set a value of a Build In Parameter, namely the profile of a slab edge but it doesn’t work. I am using the Parameter Set Method with which I had success in the past.

Does anyone have an idea what I am doing wrong?

import clr
# Import RevitAPI Classes
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)

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

clr.AddReference("System")
from System.Collections.Generic import List

import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)
import System

doc = DocumentManager.Instance.CurrentDBDocument

UIunit = Document.GetUnits(doc).GetFormatOptions(UnitType.UT_Length).DisplayUnits


Profile_P = BuiltInParameter.SLAB_EDGE_PROFILE_PARAM
Profile_N = IN[0]
famType = UnwrapElement(IN[1])
# Code unterhalb dieser Linie platzieren

TransactionManager.Instance.EnsureInTransaction(doc)

new_type = famType.Duplicate("TEST_SLAB_EDGE2")

new_type.get_Parameter(Profile_P).Set(Profile_N) 

new_type_profile = new_type.get_Parameter(BuiltInParameter.SLAB_EDGE_PROFILE_PARAM)

TransactionManager.Instance.TransactionTaskDone()

OUT = new_type_profile.AsValueString()

So the newly created Slab Edge type retains the same profile as the original one instead of having the “Dreieckig:400 x 45” Profile

Hi @borna.molnar-erhatic

IN[0] should be ElementId object type, current you’re feeding as Int64. Try this:

import clr
# Import RevitAPI Classes
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)

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

clr.AddReference("System")
from System.Collections.Generic import List

import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)
import System

doc = DocumentManager.Instance.CurrentDBDocument

UIunit = Document.GetUnits(doc).GetFormatOptions(UnitType.UT_Length).DisplayUnits


Profile_P = BuiltInParameter.SLAB_EDGE_PROFILE_PARAM
Profile_N =  ElementId(IN[0])
famType = UnwrapElement(IN[1])
# Code unterhalb dieser Linie platzieren

TransactionManager.Instance.EnsureInTransaction(doc)

new_type = famType.Duplicate("TEST_SLAB_EDGE2")

new_type.get_Parameter(Profile_P).Set(Profile_N) 

new_type_profile = new_type.get_Parameter(BuiltInParameter.SLAB_EDGE_PROFILE_PARAM)

TransactionManager.Instance.TransactionTaskDone()

OUT = new_type_profile.AsValueString()

4 Likes

Thanks a bunch!