Conduit fitting length

Greeting everyone,

I am new to Dynamo and have been assigned a task to design a script to calculate length of a conduit fitting. I have an idea how it can be calculated on paper, however, no idea how todo it in Dynamo.

In picture above we have:
L - length we want to find;
a - angle of conduit fitting;
y - which is predefined value of 10mm;
x - radius, if conduit has a nominal radius of 10mm then x = 13.8mm, however, it would be good to implement formula to calculate x depending on nominal radius of conduit;

Total length of conduit fitting would consist of 2y+L.

Please, share your ideas, tips on how to solve this.

@vlad.aleksandrovs ,

that could be a starting point


grafik

1 Like

LENGHT v2.dyn (21.6 KB)

@Draxl_Andreas

Am I correct that in terms of this script x must be created as a project parameter (instance) for conduit fitting? As well as L?

Also I am getting these errors while trying to recreate your script.

Hello
a solution using the CoordinateSystem of the connectors of the fittings (without extract geometry)

import clr
import sys
import System
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
import Autodesk.DesignScript.Geometry as DS

#import Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
import Autodesk.Revit.DB as DB

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
	
def get_length_fitting(elem):
	"""
	return the arc geometry an the length
	"""
	if hasattr(elem, "MEPModel"):
		conSet = elem.MEPModel.ConnectorManager.Connectors
		if conSet.Size == 2:
			pair_sys_origin = [[con.CoordinateSystem, con.Origin] for con in conSet]
			pta = pair_sys_origin[0][1].ToPoint()
			ptb = pair_sys_origin[1][1].ToPoint()
			vector = pair_sys_origin[0][0].BasisZ.Negate().ToVector()
			arc = DS.Arc.ByStartPointEndPointStartTangent(pta, ptb, vector)
			return arc.Length
		else:
			return None #The fitting have more than 2 connectors
	return None #The Element is not a fitting

toList = lambda x : x if hasattr(x, '__iter__') else [x]

#Preparing input from dynamo to revit
lstfitting = toList(UnwrapElement(IN[0]))

OUT = [get_length_fitting(e) for e in lstfitting]
1 Like

@dr.hybride ,

Will the script work without custom node?

Reply to dr.hybride

Additionally, does this script lead end result somewhere to check it?

Hi @c.poupin ,

How does this solution work? Code runs via Python or …? I am not familiar with coding.

download MEPover in the package

yes, here the dyn file
get_length _pipe_fitting.dyn (6.4 KB)

@dr.hybride

Got it! Getting this warning now. Also where can I find the result of calculation?

Reply to dr.hybride2

thank you!!!

@c.poupin

Tried it, but the result doesn’t match the manual calculation.

Reply to c.poupin

Got it! But the result is way off the manual calculation.

Reply to dr.hybride3

he is getting the centre arc of the fitting, where you are getting the outer arc

do you know how to get the centre length from Tee too? :flushed:

may be because of the unite

yes, the arc is calculated according to the characteristics of the connectors
like the red curve in the picture below

if you need more length precision, this method may not be the best one, see the @Draxl_Andreas 's solution

nope, maybe to study