# Datashape raybounce is missing output

**URL:** <https://forum.dynamobim.com/t/datashape-raybounce-is-missing-output/78655>\
**Category:** Packages\
**Tags:** python\
**Created:** [July 14, 2022, 2:01am UTC](https://forum.dynamobim.com/t/datashape-raybounce-is-missing-output/78655 "2022-07-14T02:01:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![newshunhk](https://avatars.discourse-cdn.com/v4/letter/n/3bc359/32.png) [@newshunhk](https://forum.dynamobim.com/u/newshunhk)\
**Post date:** [July 14, 2022, 2:01am UTC](https://forum.dynamobim.com/t/datashape-raybounce-is-missing-output/78655/1 "2022-07-14T02:01:13Z")

</div>

```auto
#Copyright (c) mostafa el ayoubi
#Data-Shapes www.data-shapes.net 2016 elayoub.mostafa@gmail.com

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

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

clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager

import System
from System.Collections.Generic import*

doc = DocumentManager.Instance.CurrentDBDocument

def tolist(input):
	if isinstance(input,list):
		return input
	else:
		return [input]

#Document UI Units
try:
	UIunit = Document.GetUnits(doc).GetFormatOptions(UnitType.UT_Length).DisplayUnits
except:
	UIunit = Document.GetUnits(doc).GetFormatOptions(SpecTypeId.Length).GetUnitTypeId()

#Inputs : Points, Direction, 3D View
if isinstance(IN[0],list):
	points = [XYZ(UnitUtils.ConvertToInternalUnits(i.X,UIunit),UnitUtils.ConvertToInternalUnits(i.Y,UIunit),UnitUtils.ConvertToInternalUnits(i.Z,UIunit)) for i in IN[0]]
else:
	points = [XYZ(UnitUtils.ConvertToInternalUnits(IN[0].X,UIunit),UnitUtils.ConvertToInternalUnits(IN[0].Y,UIunit),UnitUtils.ConvertToInternalUnits(IN[0].Z,UIunit))]

direction = XYZ(IN[1].X,IN[1].Y,IN[1].Z)
view = UnwrapElement(IN[2])

ex = []
pts = []
elems = []
categories = tolist(IN[3])
catfilters = []
for i in categories:
	catfilters.append(ElementCategoryFilter(System.Enum.ToObject(BuiltInCategory, int(str(i.Id)))))
catfilterlist = List[ElementFilter](catfilters)
filter = LogicalOrFilter(catfilterlist)

ri = ReferenceIntersector(filter,FindReferenceTarget.All,view)
ri.FindReferencesInRevitLinks = True

for p in points:
	ref = ri.FindNearest(p,direction)
	if ref == None:
		pts.append(None)
		elems.append(None)
	else:
		refel = ref.GetReference()
		linkinstance = doc.GetElement(refel.ElementId)
		try:
			elem = linkinstance.GetLinkDocument().GetElement(refel.LinkedElementId)
			elems.append(elem)
			refp = ref.GetReference().GlobalPoint
			pts.append(Point.ByCoordinates(UnitUtils.ConvertFromInternalUnits(refp.X,UIunit),UnitUtils.ConvertFromInternalUnits(refp.Y,UIunit),UnitUtils.ConvertFromInternalUnits(refp.Z,UIunit)))
		except:
			if not IN[4]:
				elems.append(linkinstance)
				refp = ref.GetReference().GlobalPoint
				pts.append(Point.ByCoordinates(UnitUtils.ConvertFromInternalUnits(refp.X,UIunit),UnitUtils.ConvertFromInternalUnits(refp.Y,UIunit),UnitUtils.ConvertFromInternalUnits(refp.Z,UIunit)))
			else:
				pts.append(None) #missing
				elems.append(None) #missing

OUT = pts , elems

```

Has anyone noticed that raybounce from datashape will sometimes export points and elements lesser than the input elements?  
I’ve modified the node and add the last two code (which have #missing), which the original code is **pass**  
Then my number of output list = input now.

I hope it helps 🙂

---

<div class="post-metadata">

**Author:** ![SeanP](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/seanp/32/42560_2.png) [@SeanP](https://forum.dynamobim.com/u/SeanP)\
**Post date:** [July 14, 2022, 3:41am UTC](https://forum.dynamobim.com/t/datashape-raybounce-is-missing-output/78655/2 "2022-07-14T03:41:01Z")

</div>

@Mostafa_El_Ayoubi

---

<div class="post-metadata">

**Author:** ![sensiblehira](https://avatars.discourse-cdn.com/v4/letter/s/43a26b/32.png) [@sensiblehira](https://forum.dynamobim.com/u/sensiblehira)\
**Post date:** [July 14, 2022, 4:22am UTC](https://forum.dynamobim.com/t/datashape-raybounce-is-missing-output/78655/3 "2022-07-14T04:22:36Z")

</div>

is your ray bounce working perfectly…I don’t know mine seems a little odd…I have many points for which I should get no intersection but I am still getting intersections at every point

---

<div class="post-metadata">

**Author:** ![sensiblehira](https://avatars.discourse-cdn.com/v4/letter/s/43a26b/32.png) [@sensiblehira](https://forum.dynamobim.com/u/sensiblehira)\
**Post date:** [July 14, 2022, 12:04pm UTC](https://forum.dynamobim.com/t/datashape-raybounce-is-missing-output/78655/4 "2022-07-14T12:04:19Z")

</div>

my concern is that if the point has to be converted to the revit’s internal units then the direction will have to be converted as well?
