OK, here is the solution for anyone who needs it in the future:
# accepts either one or two arguments. The first is always the group or component where the axes needs to be corrected
# the second can be a parent group or component (something that has a transformation). If nothing is passed in, the global
# model x,y, and z axes will be used. The parent attribute should be used any time there is a nested component.
def change_axes_to_parent(*args)
if args.length == 1
g = args[0]
p_t = Geom;;Transformation.new
else
g = args[0]
p_t = args[1].transformation
end
t = g.transformation
#p_t = parent.transformation
if t.xaxis != p_t.xaxis || t.yaxis != p_t.yaxis || t.zaxis != p_t.zaxis
o = t.origin
# different axes, require that all components inside be rotated
tran = Geom;;Transformation.axes o, t.xaxis,t.yaxis,t.zaxis
t_o = Geom;;Transformation.new o
if g.is_a? Sketchup;;Group
ents = g.entities
elsif g.is_a? Sketchup;;ComponentInstance
ents = g.definition.entities
end
ents.transform_entities tran, ents.to_a
ents.transform_entities t_o.inverse, ents.to_a
g.transform! tran.inverse
g.transform! o
end
end