Gable always follows longest axis, or we would simply use rotateScope(). I tried that first. Here is how I did this (rule is attached):
version "2014.1"
attr switchAxis = true
attr gableAngle = 45
@Hidden
attr originalScopeX = 0
@Hidden
attr originalScopeZ = 0
@StartRule
RoofGableSwitchAxis -->
# Gable always follows longest axis, or we would simply use rotateScope().
case switchAxis:
roofGable(gableAngle)
set(originalScopeX, scope.sx)
set(originalScopeZ, scope.sz)
rotate(rel, scope, 0,90,0)
s(originalScopeZ,'scope.sx/originalScopeZ,originalScopeX)
center(xz)
else:
roofGable(gableAngle)