Get current ortho angle, rhinoscriptsyntax

Hi @pascal

Is it possible to retrieve the current ortho angle, change the ortho angle, run a command / macro, say something like this:

_-NamedCPlane _Save TEMP Enter
_ProjectOsnap _disable
_CPlane _Elevation _pause
_ProjectOsnap _enable
_CPlane _3Point _pause _pause _pause
_BoundingBox _pause _C=CPlane enter
_-NamedCPlane _restore TEMP Enter
_-NamedCPlane _delete TEMP Enter

(I am able to script the above)

and then restore original ortho angle

I can only find “rs.Ortho” in both rhinoscriptsynatax and rhinoscript, which only allows a bool value.

Hi Arcade - here is a thing that will let you get or set the ortho angle in degrees:

import Rhino

def OrthoAngle(angle=None):
    
    if angle is not None:
        Rhino.ApplicationSettings.ModelAidSettings.OrthoAngle = Rhino.RhinoMath.ToRadians(angle)
        
    return Rhino.RhinoMath.ToDegrees(Rhino.ApplicationSettings.ModelAidSettings.OrthoAngle)

If you pass it no angle, as in x = OrthoAngle() it will just give you back ‘x’ as the current angle, if you give an angle, as in OrthoAngle(45) it will set that as the ortho angle and return that as well .
You do need to import Rhino at the top of your script.

import Rhino
import scriptcontext as sc

def OrthoAngle(angle=None):
    
    if angle is not None:
        Rhino.ApplicationSettings.ModelAidSettings.OrthoAngle = Rhino.RhinoMath.ToRadians(angle)
        
    return Rhino.RhinoMath.ToDegrees(Rhino.ApplicationSettings.ModelAidSettings.OrthoAngle)
    

# get Rhino's current ortho angle
crntAngle = OrthoAngle()

# store the angle
sc.sticky["ORTHO_ANGLE"] = crntAngle

"""

# do some stuff that involves changing the ortho angle
#blah-blah



"""

# now get the stored angle back from storage and restore it as Rhino's OrthoAngle:
    
# first check to make sure there is an angle stored
if "ORTHO_ANGLE" in sc.sticky:
    angle = sc.sticky["ORTHO_ANGLE"]
    
    # if there is one stored, then use it to restore Rhino's OrthoAngle
    # using the OrthoAngle function above:
    OrthoAngle(angle)
    
    # Then clear the key/value in sticky so that you can start over on the next time through:
    sc.sticky.pop("ORTHO_ANGLE")
  

-Pascal