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.
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…
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.
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…
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 ?
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)
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.