Accessing Advanced Options via script

Hi All,

Is it currently possible to access (read and change) the Advanced Options in Rhino 6 via scripting (RhinoScript, Python, RhinoCommon) ? The command line has no access to it.
I am trying to modify or disable some options for the script runtime and restore them back once it finishes.

Thanks for any suggestions.

–jarek

Not that I am aware of. FWIW most of the advanced options for Raytraced are available through the command RhinoCycles_SetAdvancedOptions.

Hi Nathan, thanks, and this is nice - I will need some of these, too.
But mainly I am trying to access/modify the keyboard shortcuts and mouse actions, plus some other random stuff.

For DisplayModes modification there was a nice addition to RhinoScript in V6 that every key and value can be modified and accessed now.

I know for Options it does not exist in RhinoScript yet, but was hoping RhinoCommon may have that exposed somehow. I am still not great at finding what is what in RhinoCommon…

–jarek

I’ll try a search after I poke @dale. Maybe there already is.

You may want to start looking at http://developer.rhino3d.com/api/RhinoCommon/html/N_Rhino_ApplicationSettings.htm

Thank you for the pointer. I will dig there!

Which settings are you trying to access? The ApplicationSettings that Nathan referenced may work for you, but if you need access to every setting in Rhino and in Plug-ins you will probably have to call PlugIn.GetPlugInSettings to access PersistentSettings. Using RhinoApp.CurrentRhinoId with this function will give you all of the core Rhino settings.

http://developer.rhino3d.com/api/RhinoCommon/html/M_Rhino_PlugIns_PlugIn_GetPluginSettings.htm

Hi Nathan, Steve, thanks again!
For now I figured out how to access and get/set the keyboard shortcut macros.
I can’t seem to find how to get/set the macro assigned to the middle mouse button though. Any suggestions?

I will look into the GetPluingSettings to see what’s out there…

You probably need to set both MiddleMouseMode and MiddleMouseMacro
http://developer.rhino3d.com/api/RhinoCommon/html/T_Rhino_ApplicationSettings_GeneralSettings.htm

1 Like

that will do it. Thanks!

So I see that I can read the MiddleMouseMode like this:

from Rhino.ApplicationSettings import GeneralSettings as gs
mmm = gs.MiddleMouseMode
print mmm

so it prints ‘RunMacro’ here.

What I am trying to do it to retrieve this value, save it as a String in RuntimeData or DocumentData, change it as needed and then reset to the original one, not necessarily within the same script runtime.

How do I go about setting the value of MiddleMouseMode to one of the 3 options (PopupMenu, PopupToolbar, RunMacro) and also how to store the original value as a string to access/assign later ?

thanks,

–jarek

Does this work for you?

import scriptcontext as sc
import Rhino.ApplicationSettings as appsettings
import System

print(appsettings.GeneralSettings.MiddleMouseMode)
sc.doc.Strings.SetString("jarek", "MM", appsettings.GeneralSettings.MiddleMouseMode.ToString())
appsettings.GeneralSettings.MiddleMouseMode = appsettings.MiddleMouseMode.RunMacro
print(appsettings.GeneralSettings.MiddleMouseMode)
mmstr = sc.doc.Strings.GetValue("jarek", "MM")
gotenum, mm = System.Enum.TryParse[appsettings.MiddleMouseMode](mmstr, True)
print gotenum, mm
if gotenum:
	appsettings.GeneralSettings.MiddleMouseMode = mm
	print(appsettings.GeneralSettings.MiddleMouseMode)

mm.py (639 Bytes)

1 Like

Thanks Nathan! It works well as a test. I need to wrap my head around it and try to understand each step and modify as needed…

If you want I can sprinkle it with human-understandable comments…

that would help :slight_smile:

import scriptcontext as sc
import Rhino.ApplicationSettings as appsettings
import System

# what have we
print(appsettings.GeneralSettings.MiddleMouseMode)


# save the middlemousemode as a string to section 'jarek' with key 'MM'
# it is a good idea to explicitly use .ToString() here to ensure the value
# gets properly converted to string form
# note that we save here as document string, so this setting is document-specific
sc.doc.Strings.SetString("jarek", "MM", appsettings.GeneralSettings.MiddleMouseMode.ToString())

# Set the new middle mouse value.
# Use the MiddleMouseMode enumeration that is under Rhino.ApplicationSettings
# which we imported as appsettings.
appsettings.GeneralSettings.MiddleMouseMode = appsettings.MiddleMouseMode.RunMacro
print(appsettings.GeneralSettings.MiddleMouseMode)

# retrieve the middle mouse value we saved.
mmstr = sc.doc.Strings.GetValue("jarek", "MM")

# parse from the middle mouse string the actual enum value. The 'generic' part of
# TryParse<TEnum> of C# is done here with square brackets in Python
# We also don't care about case-sensitivity of the original string
gotenum, mm = System.Enum.TryParse[appsettings.MiddleMouseMode](mmstr, True)
print gotenum, mm

# if the parse was successfull we can set the retrieved value to 
# be the new MiddleMouseMode.
if gotenum:
	appsettings.GeneralSettings.MiddleMouseMode = mm
	print(appsettings.GeneralSettings.MiddleMouseMode)

mm.py (1.4 KB)

Thanks a lot, this helps me greatly!

Happy typing hours!

1 Like

You may want to use the scriptcontext.sticky dictionary instead of converting enums to strings and storing them on the document.

Thanks Steve - I will look into Sticky. I am exploring many options - in some cases I will need to put the strings in a place that can be accessed both via Python and RhinoScript, depending on current need.

hi @nathanletwory @jesterking, @stevebaer,

Continuing this one - where would I find the setting for this MMB view manipulation setting:

I’d like to be able to switch it ON/OFF and GET the current setting from Python. I can’t find it where the other above settings are.