SpatialElementTag()

Hello, I’ve been trying to change an AreaTag (SpatialElementTag class) by the following method:

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


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

doc = DocumentManager.Instance.CurrentDBDocument

#areaTags = UnwrapElement(IN[0])
type = IN[1]
areaType = IN[2]

out = []
ids = []
typeIds = []
parameters = []

areaTags = FilteredElementCollector(doc, doc.ActiveView.Id).OfClass(SpatialElementTag)
for areaTag in areaTags:
    id = areaTag.GetTypeId()
    out.append(id)
    validTypes = GetValidTypes(doc, areaTag)
out.append(validTypes)

a = Transaction(doc, 'Set Spatial Element Tag')
a.Start()
for tag in areaTags:
    for t in tag:
        t.ChangeTypeId(validTypes[2])        
a.Commit()
   
OUT = out

It seems the methods GetValidTypes() and ChangeTypeId() are not valid names and are unrecognizable although they appear within the API, I can’t find where am I missing a reference or a library.

Thank you very much,

Paula Echeverri Montes

Hi @echeverrimontes and welcome

Hello,
Its an overload issue with PythonNet 2.5.2

some solutions

  • Use IronPython engine

  • Try to use the static methods instead (when available)

  • Use .Net Reflection to invoke the good overload method examples here:
1 Like

Thank you very much Cyril,
Paula EM

1 Like