Hi,
I’m facing an issue working inside a family (Planting) and trying to set the value of a parameter (Height) with data|shapes [Set Active Family Parameter By Name], after retrieving the max height value from an imported CAD geometry. Length unit is set to millimeters (relevant below).
#All the credit for this node goes to Dimitar Venkov @5devene
#Thanks for all the usefull stuff you share Dimitar!
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import*
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
UIunit = Document.GetUnits(doc).GetFormatOptions(UnitType.UT_Length).DisplayUnits
def convunit(x):
return UnitUtils.ConvertToInternalUnits(x,UIunit)
param_name = IN[0]
param_value = IN[1]
param_list = doc.FamilyManager.GetParameters()
names = [p.Definition.Name for p in param_list]
par1 = None
if param_name in names:
par1 = param_list[names.index(param_name)]
if par1 != None:
TransactionManager.Instance.EnsureInTransaction(doc)
try :
try:
doc.FamilyManager.Set(par1,convunit(param_value))
OUT = 'Success'
except:
doc.FamilyManager.Set(par1,param_value)
OUT = 'Success'
except:
OUT = 'Check parameter type'
TransactionManager.Instance.TransactionTaskDone()
else :
OUT = 'No parameter found by that name'
The issue is as follows :
With the default node above (supposedly working with internal units), I only ever get a null result, and the Hauteur parameter (Height, pardon my french) remains at its default value
I altered the script to get rid of anything related to unit conversion and finally got it to work, BUT the value is now wrong. It seems as if the node is reading the input value as inches and converting it all by itself to millimeters.
My Python proficiency is laughable at best (painfully working on it), and while I read some relevant topics around here dealing with related issues, I’m still a bit lost regarding the next steps, so I could use some hindsight regarding either issue.
Thanks in advance!