The picture below shows how doors are orientated with respect to the spaces they are found in.
As discussed in one of my earlier blogs, the door facing and hand orientations are defined as follows within the door family: http://www.mgfx.co.za/revit-door-hand-facing-orientations/
Now consider the Dynamo script illustrated below where this blog will illustrate graphically what is happening in the code blocked in red:
Consider the diagram below:
xP = in direction of project East
yP = in direction of project North
zP = in direction of Up
O = project origin
x = door origin x-ordinate defined with respect to project base point
y = door origin y-ordinate defined with respect to project base point
P = point (x,y,0)
x1 = in direction of Door Facing Orientation
y1 = defined with reference to x1 and z1 in a right-handed rectilinear coordinate system (see below)
z1 = in direction of Up
P1 = P offset by 1 in direction of y1
x2 = in direction of Door Opening Orientation
y2 = in direction of Door Facing Orientation
z2 = defined with reference to x2 and y2 in a right-handed rectilinear coordinate system
P2 = P offset by 1 in the direction of x2
For each of all the elements of the door category
Create a coordinate system (corresponds to subscript 1 above) on a plane with the origin of the door location, with the x axis in the door facing orientation and the z axis up.
Create (translate) point P2 a unit distance from the door location in the direction of x2 (the door opening orientation).
Create point P1 a unit distance from point P in the direction of y1.
Test if P1 and P2 are coincident by measuring the distance between them and checking if it is zero. If P1 and P2 are coincident, then the door is left opening, otherwise it is right opening. Set the “Side opening” parameter for the doors to either “Left” or “Right” according to this test.