Python Dimension.Below = calculated value based on actual Dimension value(Maths)

I saw you guys updated it already but here is my version of it. I set it up to be fully customizable in Dynamo Player as well.
dimComment.dyn (13.4 KB)

dimComment dimCommentDyn

Python:

# Enable Python support and load DesignScript library
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

# Functions
def getForm(dim, brick, brickN, seam, seamN):
	val = round(dim.Value * ftmm)
	x = str(int(round(val / brick)))
	if val % brick == seam:
		form = x + brickN + " + " + seamN
	elif val % brick == brick - seam:
		form = x + brickN + " - " + seamN
	elif val % brick == 0:
		form = x + brickN
	else:
		form = str(int(val // brick)) + brickN + " + R"
	dim.Below = form
	return form


# The inputs to this node will be stored as a list in the IN variables.
allDims = UnwrapElement(IN[0])
brick = IN[1]
seam = IN[2]
brickN = IN[3]
seamN = IN[4]
ftmm = 304.8

forms = []
TransactionManager.Instance.EnsureInTransaction(doc)
for dims in allDims:
	if dims.Value == None:
		form = []
		for dim in dims.Segments:
			form.append(getForm(dim, brick, brickN, seam, seamN))
		forms.append(form)
	else:
		form = []
		form.append(getForm(dims, brick, brickN, seam, seamN))
		forms.append(form)
TransactionManager.Instance.TransactionTaskDone()

OUT = forms
3 Likes