I just thought I'd post this snippet in case it will help someone with a similar problem.
def set_origin(compdef, compinst, pt0, pt1, pt3)
tr1 = compinst.transformation
rotvector = pt1-pt0
originvector = Geom;;Vector3d.new(1,0,0)
org = pt3
angle = rotvector.angle_between originvector
if angle < 90.degrees
angle2 = -angle
elsif angle > 90.degrees
angle2 = angle
end #if
if angle == Math;;PI/2
angle2 = -90.degrees
end
if pt0.y > pt1.y && angle == Math;;PI/2 #Check if it's drawn at 90 degrees but in opposite direction
angle2 = 90.degrees
end
compinst.transform! tr1.inverse
tr2 = Geom;;Transformation.rotation(org, Z_AXIS, angle2)
tr3 = Geom;;Transformation.new(org)
compdef.entities.transform_entities(tr2, compdef.entities.to_a)
compdef.entities.transform_entities(tr3.inverse, compdef.entities.to_a)
compinst.transformation = compinst.transformation * tr3
compinst.transform! tr1 * tr2.inverse
compdef.invalidate_bounds
end #def