IsPointInRoom For Different Coordinate System Linked File

Use-Case:
Model linking in architecture models with room elements and information, using the api to find the linked arch rooms that correspond with native points in my (host) model:

archDoc.IsPointInRoom(pt)

Issue:
The above works well when model origins and coordinate systems are the same. However, as with many point discrepancy issues, when model coordinate systems and origins do not match, the queried points will be different as well. I understand that and I understand there is a total transform involved. With that said, I am having trouble finding a way to transform my points (points in my model) to be aligned to the coordinate system of the linked model I am querying. For example, say the linked room point is (-500, 20, 100). A family I have centered in that room in my model has a location point of (-40, 20, 100). When I get the transform of the linked model and use Geometry.Transform on the room’s point, it returns a point that makes sense relative to my coordinate system. However, when I use Geometry.Transform on my family point with the link model transform, it doesn’t give me a point that makes sense in the linked model coordinate system. Any ideas how to make this work? Thanks.

I am basically trying to convert my native points to new points that work in the CS of the linked model so that I can place them in the code:

archDoc.IsPointInRoom(transformedpt)

so that they will now work for the archDoc to find rooms.

Look into the Geometry.Transform node which takes two coordinate systems. One of those coordinate systems is the identity coordinate system (CoordinateSystem.Identity();) and the other is the transform of your link instance. With this info you can convert the points as needed with the Dynamo UI as a means of verification.

From there you can look at transforming your points in the Revit API.

I suggest building a “link” model with a line from (0,0,0) to (10,0,0) and then linking that into a “container” model with a rotation (say 90 degrees) and offset (say 5 units) so the link is from (5,0,0) to (5,10,0). Then draw points on the same linked line inside the container file (the start, end and middle point should work). You can then confirm you have translated the points correctly when you get values of (0,0,0), (5,0,0), and (10,0,0).

After that start to deal with the rooms. :slight_smile:

Thanks Jacob. I thought about using that other Geometry node, however I wasn’t sure what the Coordinate System Identity node is, which seems to just be a 0,0,0 origin. Does the identity node represent the current model’s coordinate system or how does it work?

It is the global coordinate system, as the origin and with the X Y and Z axis aligned to the global X Y and Z axis. Every point in the active file is relative to this.