RayBounce to work on linked files

Hello. Have you been able to get RayBounce to work on linked files? I’m having trouble myself.

Try bakery or data shapes package: https://data-shapes.net/2016/10/15/raybounce-on-a-linked-model/

1 Like

Hi @clooz8 ,
I have seen your comment on the data-shapes blog. The nodes in data-shapes should be working fine. I just tested them . Could you share a screenshot of your graph so we can see where it might go wrong?

I’m a beginner at Dynamo so I could be overlooking something simple. I’m attempting to retrieve the ceiling height from the linked architectural model and importing that ceiling height into the Limit Offset of my Spaces in my MEP model.

@clooz8 ,
you’re right there’s actually an issue with that node. I fixed it but I’m having a hard time updating the package right now. So I suggest you open the custom node and replace what’s inside the python node with the following :

#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

doc = DocumentManager.Instance.CurrentDBDocument

#Document UI Units


UIunit = Document.GetUnits(doc).GetFormatOptions(UnitType.UT_Length).DisplayUnits

#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 = []
_category = IN[3]
filter = ElementCategoryFilter(System.Enum.ToObject(BuiltInCategory, _category.Id))
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:
		refp = ref.GetReference().GlobalPoint
		pts.append(Point.ByCoordinates(UnitUtils.ConvertFromInternalUnits(refp.X,UIunit),UnitUtils.ConvertFromInternalUnits(refp.Y,UIunit),UnitUtils.ConvertFromInternalUnits(refp.Z,UIunit)))
		refel = ref.GetReference()
		linkinstance = doc.GetElement(refel.ElementId)
		elem = linkinstance.GetLinkDocument().GetElement(refel.LinkedElementId)
		elems.append(elem)


OUT = pts , elems

1 Like

Got some progress, but still getting null values.

would you mind sharing your definition ?

20170611-raybounceRoomsCeilings.dyn (23.9 KB)

Just feed the “Category” input a single category instead of a list of categories :

Nice workflow by the way ! :slight_smile:

I wish I could take the credit, but @john_pierson did the heavy lifting. RayBounce appears to be working now, thank you so much! There seems to be one more piece to this puzzle. Do you know why I’m getting an empty list when I try to get and set my parameters?

2 Likes

It’s because that test you run in the “Determines if the room has ceiling above it” group is failing. The category is “CeilingS” with an s.

The consequence is your getting empty lists out of the “in” output of List.FilterByBooleanMask :

Alright, so I used the Categories node instead of the ceilings I retrieved from the linked file, but now I’m getting an error with the parameters.

For Element.GetParameterValueByName, I get:
Warning: Internal error, please report: Dereferencing a non-pointer.

For Element.SetParameterByName, I get:
Warning: Element.SetParameterByName operation failed.
The call is ambiguous between the following methods or properties: ‘Revit.Elements.InternalUtilities.ElementUtils.SetParameterValue(Autodesk.Revit.DB.Parameter, Revit.Elements.Element)’ and ‘Revit.Elements.InternalUtilities.ElementUtils.SetParameterValue(Autodesk.Revit.DB.Parameter, string)’

What’s the error message returned by “Element.GetParameterValueByName” ?

Warning: Internal error, please report: Dereferencing a non-pointer.

What is the “Clear list” node for ? I think that using the output of the “==” node as a mask should work fine.

I just took out “Clear List” and still got the same error.

Actually after taking a closer look a the definition in general, something seems a bit off… You’re trying to set the space height using the ceiling offset value right?

this should work better:

  1. Getting the location point of the spaces and using raybounce to get the ceilings above them

  1. Using the result of the raybounce to filter the list of ceilings and the matching list of spaces, then setting the height of the spaces :
1 Like

Odd, I’m still getting the errors.

I think you’re getting close to having something that works. Try making these changes :

1 Like

So, I gave up on the model I’ve been working on, but decided to try it on a different one. It worked! …Except it only worked on Spaces that I did not place in the model. So, I’m going to try and play around with it some more and see if I can figure something out. Let me know if you have any other ideas.