View filter rules values don't match parametric values due to unit conversion

I am relatively new to Dynamo so please bear with me. I have read that Dynamo is unitless, but in that same article, there is mention of the units conversion node. Is this because Dynamo is not unitless or that the Revit (API) defaults to feet (I am having problems with values from a metric/meters model). Either the FilterRule.ByRuleType node or Revit converts values harvested from metric (M) model to feet when writing the view filter rules values.

The result is that there is a mismatch between the floors’ parametric value Elevation at Top Survey read from the model and the view filter rules’ value written by Dynamo, so that the floor color overrides do not display until I manually go in and re-select the rule value from the pull-down in the Filter Rules window. I believe there is non-zero decimal value beyond those that display in that field.

I had a much longer description of this written up, with images and plans to upload the script (and possibly a pared-down model) but as a new user on this forum, I get a message that I can’t upload files. So I am starting with this bare-bones description.

If you understand the issue, do you have suggestions/programmatic work-arounds (including Python, which I am interested in learning). OR let me know if you need more information.

Thank you in advance for your time and insight!

what i would do is use revit’s built in API to do its conversion in a method. So in the python script, i would call a def of :

def ToUnitType(famdoc, unitType, val, toRevit):
	UnitTypeWithDisplayUnitType = dict()
	gunit = famdoc.GetUnits()
	unit = Units.GetModifiableUnitTypes()
	for ut in unit:
		if UnitType.UT_Undefined == ut or UnitType.UT_Custom == ut: continue
		else:
			fo = gunit.GetFormatOptions(ut).DisplayUnits
			UnitTypeWithDisplayUnitType.Add(ut, fo)
	if toRevit == True:
		return UnitUtils.ConvertToInternalUnits(val, UnitTypeWithDisplayUnitType[unitType])
	else:
		return UnitUtils.ConvertFromInternalUnits(val, UnitTypeWithDisplayUnitType[unitType]) 

whereby,
famdoc is just any document, usually it will be the current active document,
unitType is the unit type of the parameter, which can be retrieved via parameter.Definition.UnitType,
val is the value of the parameter (usually is double), and
toRevit is a boolean whereby it determine if the value is to revit or from revit.

1 Like

Thank you, stillgotme! Python is on my to-learn list so this will give me jump start.

I ended up handling it in Dynamo with 2 updates (with help from a colleague):

  • replaced my manual 11-decimal place unit conversion node with Dynamo’s out-of-box unit conversion node. That got many, but not all, filters to display
  • replaced a single equal to rule with 2 rules- greater than and less than. This captured those values in those far-right decimal places and the rest of the filters displayed.

Again- I really appreciate your help and the Python code! I will check that out.