Need Help for UI

Hi guys,

Here is my issue: I have a plugin which has 3 commands in it. Each command needs 7 or 8 inputs data, all the data are number or string. After accepting the dialog data, user will have to select a brep & other edges on the brep. Now my question is how to make the input procedure more user friendly. If I ask user to type each data or hit return to accept a default, then user will have to hit return many times. Another way is to create a input dialog which is what I did now, so every time user will have accept the dialog data or change it. But will the dialog-way affects the script running in rhino? say user records each steps to create a model, then run the script to automate the creation. Are there better way? is there a standard way in rhino to handle this scenario?

Thank you
Regards
John

Hi,
You want to make a custom input with option values, that way user can click enter once, or update whatever setting he may want to update if needs changing.
The UI is fine, the way to do in “native” rhino without having any sort of UI would be to make the custom input.

Example :

import Rhino
import rhinoscriptsyntax as rs
import Rhino.Geometry as rg

if __name__ == '__main__':
    DrawSurfaces = True

    cmd = Rhino.Input.Custom.GetObject()
    cmd.SetCommandPrompt('Select the curves.')
    cmd.GeometryFilter = Rhino.DocObjects.ObjectType.Curve
    
    opDrawSurfaces = Rhino.Input.Custom.OptionToggle(DrawSurfaces, 'No', 'Yes')
    cmd.AddOptionToggle('DrawSurfaces', opDrawSurfaces)

    Done = False
    
    while not Done:
        result = cmd.GetMultiple(1, 0)
        
        if result == Rhino.Input.GetResult.Option:
            DrawSurfaces = opDrawSurfaces.CurrentValue

        else: Done = True

    print 'Draw Surfaces Option: ' + str(DrawSurfaces)

    for obj in cmd.Objects():
        print obj.ObjectId

Hope this gives you some ideas,
Farouk

Summary

If you want some help with your software, reach out to me at farouk.serragedine@gmail.com

Hi Farouk,

thank you very much. Is the dialog input will have problems when user want to create a script?

Regards
John

Hi,
The way I do it is that I link a letter for each option

Let’s make a practical example :slight_smile:
Script to draw circles with Radius input value.
The user can script “YourCommand R 150” if you have linked the letter R to the input options RADIUS.

I hope that was clear

Farouk

Hi Farouk,

I am sorry I didn’t make my issue clear. I want to know whether user can still create a rhino script with my plugin command if I use MFC dialog as input interface for users.

Thank you.
Regards
John

Hi @smartunfold,

Considering structuring your command like this:

CRhinoCommand::result CCommandTestJohn::RunCommand(
  const CRhinoCommandContext& context
)
{
  CRhinoCommand::result rc = CRhinoCommand::success;

  if (context.IsInteractive())
  {
    // TODO: Show MFC dialog interface here.
    // Set value of rc
  }
  else
  {
    // TODO: Show command line interface here
    // Probaby a CRhinoGetOption objects with an number of command line options.
    // Set value of rc
  }

  if (rc == CRhinoCommand::success)
  {
    // TODO: continue picking Breps, edges, etc.
  }

  return CRhinoCommand::success;
}

– Dale

Hi Dale Fugier,

Thank you very much. I will change my codes to implement your suggested approach.

Regards
John