Here is a Macro that should help you with rotation and X/Y center position.
Just input your Segment and set rotation Angle and Hinge Center.
There is a checkbox that switches rotation along X or Z axis rotation depending on your Style. (1LS or A2S)
Segment Size should override segment thickness and set user value to frame thickness only ( without e.g. handle).
The alignment parameters will select alignment on the Y/Z Axis and cycle alignment: 1-Pivot, 2-Bottom,3-Center,4-Top,5-Automatic.
Need some experimenting but eventually, you will catch it