Help needed: add to "never-repeat commands" list via script

Hi,

I have been trying to figure out a way to add a command to the never-repeat list via script, and because of the way they are remembered in Options, I am having hard time with this one.

With a great help from this forum I was able to figure out how to get/set most of the Advanced Options in Rhino via Python code. And to some degree can do the same with this one, but the list is remembered as two parameters: 1) count of never-repeat commands; 2) individual commands, numbered, as their own options items.

Here is my code to check for the number of commands and to list them:

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

settings = Rhino.PlugIns.PlugIn.GetPluginSettings(Rhino.RhinoApp.CurrentRhinoId, False)
dontrepeat = settings.GetChild("Options").GetChild("DontRepeatCommand")
count=dontrepeat.GetInteger("DontRepeatCount")

commands=""
for i in range(0, count-1):
    prefix=""
    if i < 10:
        prefix="0"    
    commands += dontrepeat.GetString("DontRepeat_" + prefix + str(i))+" "

print "don't repeat count:" + str(count)
print "don't repeat commands: " + commands

But how would I go about adding another one to the list? Is there a way to add a key to this list using similar code to the above? Would I need to manually change the commands count then? Or maybe should I look into editing the settings xml file directly?

This is how they look in Advanced Options, and the code above uses same names to read the settings:
Capture

A secondary question that may affect the code above - in a very unlikely scenario with less than 10 commands, would the entry still keep the 0 prefix before the single digit? And what if we are more than 100 (doubt it would ever happen) - would they change to 001, 002… etc.?

My main goal for now is to add a command to that list from code.
@stevebaer, @nathanletwory - since you helped a lot with figuring out accessing the Advanced Options maybe you could with this one too ?

thanks!

–jarek

This is probably an easier way to access and set this list
https://developer.rhino3d.com/api/RhinoCommon/html/T_Rhino_ApplicationSettings_NeverRepeatList.htm

2 Likes

Phew, glad I first started testing a bug fix before looking into this :smiley: Saves me from even trying to script this through the advanced options…

1 Like

Great, thanks! I will give it a shot - from the help description it looks like it will be much easier that way indeed :slight_smile:

Thanks again @stevebaer, this works:

    import Rhino.ApplicationSettings as appsettings
    from System import Array

    #get list of never repeat commands
    neverrepeat = appsettings.NeverRepeatList.CommandNames()

    #add command to the list
    neverrepeat_new = list(neverrepeat)
    neverrepeat_new.append("new_command")

    #update the list
    updatedlist=Array[str](neverrepeat_new)
    appsettings.NeverRepeatList.SetList(updatedlist) 
2 Likes

Hello @Jarek,

How to use python set the idle processor command to run? I want to set command to run with idle processing. Thank you.

I know the macro: _-Options _IdleProcessor _Enabled=Yes _Seconds=300 _EnterEnd

Hi Alen,
I am not sure how to access that setting via RhinoCommon in Python, but you can use rhinoscriptsyntax and use rs.Command to pass your macro there.

@Jarek,

Thanks for your help.

How to use rhinoscriptsyntax to pass my macro there?

here is a sample for the help file:

import rhinoscriptsyntax as rs
rs.Command("_Line 0,0,0 2,2,2")
rs.Command("_Line _Pause _Pause")

Hi @Jarek,

I want to add IncrementalSave command to idle processing, but I cant find any code with python.

Hi Alen,
I can’t find anything relevant; I don’t see it anywhere in Advanced Options that can be accessed via Python. It is possible that this is not exposed anywhere. Sorry, I don’t know the answer.