Dear Jeremy,
Thanks for your interest. I tried to attach two files (about 7 MB in total) but after clicking to "Post" button message is not submitted. I suspect that reason is file size. So I uploaded botfh files in one Zip file on WeTransfer. You can download it here
In downloaded file (Sample.zip) you will find two files Host1.rvt and Link1.rvt. Please open Host1.rvt. In that file Link1.rvt is linked.
- Please make view "Wall in host file" active. In that view one conduit and one wall (modelled in Host1.rvt) is shown.
- Now run macro: TestFindNearest which is included in Host1.rvt.
- Revit should respond with TaskDialog showing 1.99999 what is projected distance between specific point (on conduit) and wall. That is expected behaviour.
- Now activate view "Wall in linked file". You will see the same -- Wall and conduit. The difference is that wall shown in this view is modelled in Link1.rvt, (conduit exists only in Host1.rvt). Wall modelled in Host1.rvt is hidden in this view similarly as it is complete Link1.rvt hidden in "Wall in host file" view.
- Run the same macro again.
- Revit responds with exception thrown in statement (please see source code) where I am trying to call CreateReferenceInLink.
If you analyse the code, you will find out that ReferenceIntersector in second case returns reference to some geometry in linked file. After that I am trying to check if returned reference is pointing to host or linked file. If it is in linked file I slightly modify the procedure how to get appropriate face. I wrote that procedure after analysing some similar (but not the same) samples on net, so it is possible that the procedure is wrong.
Actually, my ultimate wish is to get the same result -- distance between point and nearest face of wall now modelled in linked file.
(Wall in Link1.rvt is not modelled on the same position as in Host1.rvt. That is intentionally. O moved origin of Link1. rvt in Host1. rvt accordingly, so that result will be the same -- 1.99999 only if procedure of retrieving distance is taking into account also relative position of linked file in host file, but up to now, due to the problem with retrieving geometry in linked file, I didn't get so far to check also that part.)
Kind regards,
Žarko