Recently I have been helping the Engineering Team create a parametric workflow for rail infrastructure using Dynamo. The nature of rail related projects are generally following certain rules and constraints, thus I found there are a lot of chances where repetitive tasks can be performed in batch via scripting. So today I was working on placing a series of overhead structures along the rail alignment, based on provided coordinates, i.e. XYZ, and very importantly, the orientation.
In Native Dynamo Nodes, it only allows rotation of a placed family instance around its Internal Axis. But in reality, things are often more complicated. To have families like overhead structures placed with the correct orientation, there are a few things to check and potentially to optimise if enough time and efforts are available.
The first important factor is the internal axis, which also defines the insertion point of a family instance. This is usually determined by how the family is modelled and often based on discipline specific or equipment type requirements, i.e. the relative location of family components to the insertion point. The second to check is the basic internal orientation, especially for families where insertion point is not at the centre of the model.
For example, if a rectangle desk is built with insertion point at top-right corner, that means the internal orientation aligns with X axis towards the -X (-1,0,0) direction as its vector. This information is important for calculating the actual angles of orientation, e.g. the angle between internal orientation vector and desired orientation vector in Dynamo/Revit project coordinate system, via node Angle-About-Axis(About Z-Axis).
With these understandings, I’ve written this tiny script for advanced family rotation, note that this node uses Revit transaction and does not have the updated family instances linked back/managed by dynamo, thus only Ctrl-Z in Revit will do a step back.
Python Script in Dynamo Node: Advanced Family Rotation