MEP.Fittingbypointsandcurve - Multiple intersections of 1 duct + others

hello there @pyXam, hope you had a goodnight rest thinking about the possible cause of this. I myself had come out something for you, and you can further develop it yourself :slight_smile:

basically the workflow is like this:
image

and the results will look like what you need:
image

whereby the python script is used to generate points on the intersection. Here is the code of the python script:

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

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

# Import ToDSType(bool) extension method
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
# Import ToProtoType, ToRevitType geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)

# Import DSCore nodes in Dynamo
clr.AddReference('DSCoreNodes')
import DSCore
from DSCore import *

# Import python library
import sys
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)
import os
import shutil
import math
# Import math library
from math import *

#Import Data and Time
from datetime import datetime
now = datetime.now()

#Import System Library
import System
from System.Collections.Generic import *
from System.IO import Directory, Path

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

def ToList(x):
	if isinstance(x,list):return UnwrapElement(x)
	else: return [UnwrapElement(x)]

linkfile = next(iter(ToList(IN[0])), None)
#get elements of multicategories
multiCat = List[BuiltInCategory]()
multiCat.Add(BuiltInCategory.OST_StructuralFraming)
#multiCat.Add(BuiltInCategory.OST_Floors)
multi_Catfilter = ElementMulticategoryFilter(multiCat)
multi_CatEles = FilteredElementCollector(linkfile.GetLinkDocument()).WherePasses(multi_Catfilter).WhereElementIsNotElementType().ToElementIds()
transform = linkfile.GetTransform()

ducts = ToList(IN[1])
ductIds = [p.Id for p in ducts]
ductIDS = List[ElementId](ductIds)

TransactionManager.Instance.EnsureInTransaction(doc)
newlist = []
for duct in ducts:
	templist = []
	IntSolidEle = []
	newsolid = next(iter(duct.get_Geometry(Options())), None)
	if not transform.AlmostEqual(Transform.Identity) : newsolid = SolidUtils.CreateTransformed(newsolid, transform.Inverse )
	IntSolidfilter = ElementIntersectsSolidFilter(newsolid)
	IntSolidEles = FilteredElementCollector(linkfile.GetLinkDocument()).WherePasses(IntSolidfilter).ToElements()
	IntSolidCurve = duct.Location.Curve
	for IntSolidEle in IntSolidEles: 
		link_solid = next(iter(IntSolidEle.get_Geometry(Options())), None)
		link_curve = IntSolidEle.Location.Curve
		IntPoint = IntSolidCurve.Project(link_curve.GetEndPoint(0)).XYZPoint
		templist.append(IntPoint.ToPoint())		
	newlist.append(templist)
TransactionManager.Instance.TransactionTaskDone()

OUT = newlist  

It should work as per your case now. I think the reason why it didnt work is because the points obtained using the solid centroid is not lying on the duct. Thats why you are having the issue. Of course you can add a few more nodes to query the parameter on the duct but it will be just like solving a problem to create another problem. So thats not efficient at all. Lets try that and see if it works for your case.

1 Like