The example script you sent works exactly opposite of what you suggest. The Duct (in a linked model) is used to cut holes in the Structural Framing in the host model.
Actually - the way this script works is that it looks at the duct in the linked model - gets it’s geometry, then uses the intersection of that geometry and the structural framing geometry to get an outline of the opening that is needed, then creates an OpeningByFace using the calculated outline. So in reality - the duct is not cutting the framing at all. The Opening By Face (which is a manually drawn if working in Revit without Dynamo - this script just automates the manual drawing of the opening) is what actually cuts the framing.
If the duct were deleted from the link - the opening would still exist (delete the entire linked file and the opening will still exist). This is different than what would occur if using join behavior in the same host model - delete the duct and there would no longer be a join (since one of the two things being joined no longer exists) so the hole would also be non-existant.
To your second question - it would be possible to look at the location line of a cable tray/duct/pipe/etc and determine the angle between the that line and the face of a wall, and then only create an opening if the angle is within some set tolerance of 90 degrees.
Lastly- i think both of your questions are good, but are off-topic from the original thread. Please post new topics on these or search for similar topics such as these: