Fittings is not connected

hi everyone,
i cannot able to connect the pipe with fitting(one side only is not coming).i don’t know. how to figure out this.
i have attached here dynamo file and cad dwg file


revit link.dwg (32.9 KB)
pipe to cad.dyn (78.6 KB)

1 Like

Hi,
in Revit API to create tee fitting, connectors (pipes) need to be ordered
(The third connector to be connected to the tee. This should be connected to the branch of the tee.)

here is a workaround with Python using vectors direction

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

#import transactionManager and DocumentManager (RevitServices is specific to Dynamo)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

def toList(x):
    if isinstance(x, list):
        return x
    elif hasattr(x, "GetType") and x.GetType().GetInterface("IEnumerable") is not None:
        return x
    else :
        return [x]
        
def get_order_connectors(elemA, elemB, elemC):
    test = elemA
    lst = [elemA, elemB, elemC]
    # create group by direction
    groupA = [i for i in lst if abs(test.Location.Curve.Direction.CrossProduct(i.Location.Curve.Direction).Z) < 0.001]
    groupB = [i for i in lst if abs(test.Location.Curve.Direction.CrossProduct(i.Location.Curve.Direction).Z) > 0.001]
    lstGroup = [groupA, groupB]
    # sort list of group by len 
    lstGroup.sort(key = len, reverse = True)
    # flat the group : the last element is the branch
    lst_sort_elem = sum(lstGroup, [])
    lst_curve_elems = [i.Location.Curve for i in lst_sort_elem]
    orderConnectors = []
    # get closest connectors
    for idxA, elem in enumerate(lst_sort_elem):
        other_curve = [c for idxB, c in enumerate(lst_curve_elems) if idxA != idxB][0]
        print(other_curve)
        closest_connectors = sorted(elem.ConnectorManager.Connectors, key = lambda c :  other_curve.Project(c.Origin).Distance)
        orderConnectors.append(closest_connectors[0])
    #
    return orderConnectors

out = []
#Preparing input from dynamo to revit
lstelemsA = toList(UnwrapElement(IN[0]))
lstelemsB = toList(UnwrapElement(IN[1]))
lstelemsC = toList(UnwrapElement(IN[2]))

#Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)
for elemA, elemB, elemC in zip(lstelemsA, lstelemsB, lstelemsC):
    conA, conB, conC = get_order_connectors(elemA, elemB, elemC)
    tee = doc.Create.NewTeeFitting(conA, conB, conC)
    out.append(tee)
TransactionManager.Instance.TransactionTaskDone()

OUT = out  
4 Likes

Thanks @c.poupin thats really great and much more stable :wink:

@thsa2501 i have tried with sizing your pipes with cads layer key, as you see its a little bit complicated as some of the cad lines isnt split so the layer dont follow the pipes, but you could try split the pipes after creation with splittool from genius loci…here is an exemple…not so elegant but could work…

Revit_cnOlNW6zdL

3 Likes

hi,
thank you so much.it works for me.lot of thanks .may i know,why its not work that mep.tee fitting?

hi,
yes,i am so confused why its not work for multiple layers at the end i am so frustrated. it works for creating pipe but not creating fittings.
thanks a lot you creating for me.

1 Like

You are welcome…here is my exemple…try play around with it :wink: good luck

guees its becoarse you will need to split mainpipe in every intersection for create fitting and then the layer will not follow…but try as here

FORUM CAD PIPES SIZING.dyn (95.9 KB)

Hi,
there is know way to create pipe and fitting according to layer.

yes its possible just create the pipe system there follow the cadlines/layer and then split after with splittool from genius loci…thats what i try to do in my exemple…i just type the size into a codeblock as i dont work in inches…but it could be automated as well

ok,i will try then let u know.thanks again dude.

1 Like

I would try to split in the acad and set layers for keys, so we dont need sort so much in dynamo revit

1 Like

hi,
sorry to ask again. its really very hard to understand your script.can you explain little bit about why using a lot of geometry intersect nodes?
1.you first used geometry intersect detected only three pipes. why not detect all pipes and how ?
2.i cannot able to find splitt tools nodes from genius loci.

yes its complicated as the layer dont follow, thats why we need find out where to split…but just an exemple and can for sure be optimized…but works…you will find the splittool in genius loci package guess under geometry, or try open mep breakline…


but best to just split in acad so layer follow pipes…can easy be done with acad lisp routine

Here i had split your cad lines so the layer follow with the lisp above…as you see it much more simple…


splitted cad FORUM CAD PIPES SIZING.dyn (64.7 KB)
breakedrevit link (1).dwg (446.2 KB)
and the lisp, just rename file extension .txt to.lsp as we cant upload .lsp files here
BreakObjects21 - Copy.txt (39.5 KB)

readme.txt (502 Bytes)

1 Like

hi,
alhamdulillah. thanks a lot ,you created for me. we can use layer also. kindly see the graph. i discovered something. i edit python script for cross fitting but i cannot able to place elbow fitting.
kindly see attached documents.
splitted cad FORUM CAD PIPES SIZING.dyn (70.4 KB)
breakedrevit link (1).dwg (470.1 KB)
fitting

allright its a new dwg…same same as already showed but now you have cross instead of tee…open mep have a node for that as well…or try modify Cyril code so it work on cross as well…good luck

1 Like

hi,
it works very well now. thanks a lot dude. may Allah bless you. :heart_eyes: :heart_eyes: