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

python
revit
dynamo

#22

It says its corrupted… i ll try to duplicate it, will get back to you guys :slight_smile:
image


#23

I am using Dynamo 2.0. I will upload again: dimComment.dyn (7.4 KB)

Leaving office for the night, let me know if it works or you have any problems and I can try to help tomorrow.


#24

Still error opening it, i ll try and duplicate it and get back to you!
The picture ur showing atleast looks like what i m trying to achieve.

Thanks!


#25

It works for me, awesome work @kennyb6!

dimMultiSegmentPy-v1.3.dyn (4.4 KB)


#26

It seems i can open @Mark.Ackerley file which should be the same as @kennyb6 gave.

anyways, it seems to work for multi segmented dimensions, but skips the single dimensions for me.

PS: This looks awesome btw :stuck_out_tongue:


#27

Ah I made it only with multi in mind as it uses the dimensionsegment class instead of dimension. I can fix it tomorrow.


#28

Super awesome <3 thx


#29

Try this…

dimMultiSegmentPy-v1.3-2.dyn (7.0 KB)

Cheers,

Mark


#30

Nice!

It should have one more option: amount of bricks
this case brick = 100 > 1000 should be 10 X
image

Bonus round: would it be possible to write the invalid dims as follows:

2018-12-13_12h20_35

5161 = 51 bricks of 100 + Rest ? like i did manual with the red dimension in the picture above.


#32

Like this?

dimMultiSegmentPy-v1.3-3.dyn (7.1 KB)


#33

image

the red value seems to make a mistake in rounding.

i put brick value at 100 and brickjoist at 10.
It should be 51X + R if calculated by hand
( 51*100 + rest) rest = 61 in this case.

The 10X is good though… i really need to learn python, this really helps alot finnishing graphs

EDIT: I took away the Round in calculating the x value in python. this fixed it
Works like a charm now.


#34

My solution messed up the K-V value now …
so basicly it wasnt the solution … i m confused which round i should have left untouched
image
The 690 value should be 7K - V in this example

@Mark.Ackerley It should only round the convertion from ft to mm
perhaps something like this:
elif val % brick == brick - sep:
form = int(ceiling(x)) + “K - V” ?


#35

Hey,

It’s quite difficult for me when you don’t upload an Rvt?

Perhaps this helps? You always want to round down i guess?

image

Hope that helps,

Mark


#36

here is a wetransfer link to my rvt: https://wetransfer.com/downloads/db16e72fea8480891f64dc2e28fd0e2620181213132537/36ff7c52782235a469dd7a4b4859b95120181213132537/6594c7

The graph you send at post #30 works best, except it rounds up somehow.
in the picture i had set brick to 100 and brickjoist to 10
X = 100, Y = 10
Here the graph:dimMultiSegmentPy-v1.3-3.dyn (7.1 KB)

image

Only the X + R values seem to go wrong if they are above half a brick
half a brick is 50 in this case.
dimensions under 5140 is good now, the dimension 5161 seems to be rounding up somehow


#37

image
this workaround seems to work.

Thanks alot, for all your time and patience haha :slight_smile:


#38

It looks good to me :slight_smile:

I’m sure the code could be tidied… We could use a Function, as we are essentially doing the same thing twice…

But then, it’s still pretty readable and a lot more simple than the node method.

Great to have a working solution!


#39

Yes, i agree.
Also this is better then the first solution i suggested.
where i let dynamo calculate 100 options and then compare with dimensions. this basicly calculates per dimension which always works also if its option 101.

Thanks again @Mark.Ackerley and @kennyb6


#40

It’s more than 3 lines… and it’s python. But still fun!

dataEnteringNode = IN
dimensions = IN[0]
x = IN[1]
y = IN[2]
values = []

for d in dimensions:
    r1 = (d + y)%x
    r2 = (d - y)%x

    if r1 == 0:
        formula = str((d + y)//x) + "X - Y"
    elif r2 == 0:
        formula = str((d - y)//x) + "X + Y"
    else:
        formula = "Invalid"

    values.append(formula)

OUT = values

#41

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)

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

Dimension override value for Above and Below
Python wrong outcome because it rounds my float value
#42

Thanks! we use datashapes and actual buttons on the Revit tab. kind of the same idea though :slight_smile:

Thx for the update