Hello everyone I do not know if you could advise me, I need to remove some wiring size based on the TemperatureRating and WireMaterial. I know that the way to eliminate them is using the RemoveWireSize method from the TemperatureRatingType class and I asked as an argument a wiring size to be able to Remove them, what I have been able to do so far is to get the list of wiring sizes that I want to eliminate, but I have not been able to unwrapping, please check the code down below thanks.
import clr
import sys
import System
#import Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB
from Autodesk.Revit.DB.Electrical import *
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *
# Import Dynamo RevitNodes
clr.AddReference("RevitNodes")
import Revit #Enable namespace typing
from Revit.Elements import *
clr.ImportExtensions(Revit.Elements) # ToDSType(bool) extension method
clr.ImportExtensions(Revit.GeometryConversion)# Import ToProtoType(), ToRevitType() extension methods
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
#Internal Definition (all custom defined functions to be in this region)
def ToList(input):
if isinstance(input, list):
return input
else:
return [input]
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
wiretype = UnwrapElement(IN[0])
result = []
#TransactionManager.Instance.EnsureInTransaction(doc)
#Main codes to be within this region
for i in wiretype:
tempRating = i.TemperatureRating
wireMaterial = i.WireMaterial
Wiresizes = tempRating.WireSizes
for ws in Wiresizes:
foundWS = [ws.Size, ws.Ampacity, ws.Diameter]
if ws.Size != "2000":
Remsz = ws.GetType()
Rem = tempRating.RemoveWireSize(Remsz)
result.append(Rem)
#End of region
#TransactionManager.Instance.TransactionTaskDone()
#TransactionManager.Instance.ForceCloseTransaction()
OUT = result