import clr
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.ExternalService import *
from Autodesk.Revit.DB.ExtensibleStorage import *
from System.Collections.Generic import *
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *
doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
def getServerById(serverGUID, serviceId):
service = ExternalServiceRegistry.GetService(serviceId)
if service != "null" and serverGUID != "null":
server = service.GetServer(serverGUID)
if server != "null":
return server
return null
lc=[]
def getLossMethods(serviceId):
service = ExternalServiceRegistry.GetService(serviceId)
serverIds = service.GetRegisteredServerIds()
list=List[ElementId]()
for serverId in serverIds:
server = getServerById(serverId, serviceId)
#ductServer = server.IDuctFittingAndAccessoryPressureDropServer
id=serverId
name=server.GetName()
lc.append(id)
lc.append(name)
lc.append(server)
return lc
elems_=UnwrapElement(IN[0])
SetNew= IN[1]
elem=[]
elems=zip(elems_, SetNew)
for el in elems:
eleId = el[0].Id
fitting =doc.GetElement(eleId)
param = fitting.get_Parameter(BuiltInParameter.RBS_DUCT_FITTING_LOSS_METHOD_SERVER_PARAM )#)
lc = getLossMethods(ExternalServices.BuiltInExternalServices.DuctFittingAndAccessoryPressureDropService)
schema = lc[2].GetDataSchema()
field = schema.GetField("ASHRAETableName")
entity=fitting.GetEntity(schema)
oldval = entity.Get[field.ValueType] (field) # obtaining values
TransactionManager.Instance.EnsureInTransaction(doc)
entity.Set[field.ValueType](field,el[1]) # SetNew # installation of a new coefficient value of certain
fitting.SetEntity(entity)
TransactionManager.Instance.TransactionTaskDone()
elem.append(fitting)
OUT = elem ,lc, oldval
and if you find way to set values to another category, please post here,
Hi Til
thank you for your effort, youâre very kind.
Your code works perfectly with Duct Fittings, too. The only problem was with Endcaps: they have only one connector, so Pressure Loss makes no sense with them. I just removed it with a list.filter in dynamo, and everithing worked perfectly.
Thank you!
ok . please paste your final code there (or dyn .file) . its may help to another people
Hereâs the final .dyn
Set ASHRAE table value according to a Type Parameter.dyn (17.7 KB)
Hello guys,
Iâve a code more or less like posted above and I got one question.
Iâm changing method to specifc coefficient and set values.
Itâs set in Revit properly etc, but calculated pressure drop parameter doesnât take into account new value, itâs empty/blank. I need to select family in UI, change pressure loss method to any other method, hit apply and revert to specific coefficient again to get this working. Do you know how to force revit to update this properly and force revit to recalculate?. I donât see anything different in my code, besides I didnât wrap code into definitions.
Hello everybody,
I have also a question.
The second Python-Code is construed for only one single string.
If I want to put a list in the node, he give me a fault.
How can I solve this Problem?
HiâŚGood script⌠I have a queryâŚCan we get the field typesâŚi.e from CR3-1 to CR3-9 in the list??. I was searching for the dynamo package and Revit API methods but canât find any. Can you please provide me with the solutionâŚThanks a lot
hello everyone, could you tell me what are the steps to follow to run the file in dynamo thank you very much.
Thanks@til.shviger. Do we have any way to export the table inbuilt values to excel? From CR3-1 to CR3-10âŚ
Hi, I am using @til.shviger code, but I am getting the same error all the time.
No method matches given arguments for Set: (<class âAutodesk.Revit.DB.ExtensibleStorage.Fieldâ> , <class âstrâ> [âFile ââ, line 74, in \nâ]
The issue is in this line:
entity.Set [field.ValueType] (field,el[1]) # SetNew # installation of a new coefficient value of certain
I think it is becouse API have been updated as this post, but not sure how to implement this in Python
Many thanks
Hi @til.shviger , could you help us here to fix the code error that myself and @ignasi are having with recent Revit versions?
Thanks