The saga of the wayword debugger continues

In the following code, setting a break point on any line has no effect. Some code is running, but it’s not this code. The dialog, a simple winform with a datagridview (not populated) and two buttons, appears. When you press the “OK” button, the dialog disappears and the prompt to select a surface appears. When a surface is selected, the dialog reappears, even though it’s not supposed to.

This is mysterious, since at one time it was designed to do this, but that functionality has been removed. As previously noted, setting a break point to find out why this is happening is pointless.

    protected override Result RunCommand(RhinoDoc doc, RunMode mode)

    frmSelectProduct form = new frmSelectProduct();
    form.StartPosition = FormStartPosition.CenterParent;
    string res = "OK";

        DialogResult dialogResult = form.ShowDialog(RhinoApp.MainWindow());
        res = dialogResult.ToString();
        if (res != "Cancel")
            Rhino.DocObjects.ObjRef obref;
            Rhino.Commands.Result rc = Rhino.Input.RhinoGet.GetOneObject("Select surface", true, Rhino.DocObjects.ObjectType.Surface, out obref);
            if (rc != Rhino.Commands.Result.Success)
                return rc;
            Rhino.DocObjects.RhinoObject rhobj = obref.Object();
            if (rhobj == null)
                return Rhino.Commands.Result.Failure;
            string name = rhobj.Attributes.Name;
            AddLayer(RhinoDoc.ActiveDoc, name);
            int layer_index = doc.Layers.Find(name, true);
            rhobj.Attributes.LayerIndex = layer_index;
            res = "Cancel";
            return Result.Success; 
            return Result.Failure;


    public static Rhino.Commands.Result AddLayer(Rhino.RhinoDoc doc, string strLayerName)
        // Is the layer name valid?
        if (!Rhino.DocObjects.Layer.IsValidName(strLayerName))
            Rhino.RhinoApp.WriteLine(strLayerName + " is not a valid layer name.");
            return Rhino.Commands.Result.Cancel;

        // Does a layer with the same name already exist?
        int layer_index = doc.Layers.Find(strLayerName, true);
        if (layer_index >= 0)
            Rhino.RhinoApp.WriteLine("A layer with the name {0} already exists.", strLayerName);
            return Rhino.Commands.Result.Cancel;

        // Add a new layer to the document
        layer_index = doc.Layers.Add(strLayerName, System.Drawing.Color.DarkGray);
        if (layer_index < 0)
            Rhino.RhinoApp.WriteLine("Unable to add {0} layer.", strLayerName);
            return Rhino.Commands.Result.Failure;
        return Rhino.Commands.Result.Success;

It sounds like the output of the build is not being loaded by Rhino. Please make sure that

  1. your project is fully built
  2. the output of the project (that is, the plug-in RHP file) is the one loaded into Rhino.

You can see in Visual Studio the path of the output file by right-clicking on the project, select Properties and then navigate to the Build page. In the lower part you find “Output path”.

Then in Rhino, go to Tools -> Options -> Plug-Ins. Find your plug-in and double-click it to show its properties. In the lower part of that dialog you find the path of the loaded plug-in.

These paths should be the same. If they are not, you should drag the RHP file that was built by Visual Studio onto Rhino before the plug-in is loaded. If the plug-in is loaded at start-up (this is discouraged by may be the case), I think you need to remove its entry from the registry when Rhino is not running. You need to find your plug-in in HKEY_USERS\Software\McNeel\Rhinoceros\5.0x64\Plug-Ins\ (each plug-in is listed by their plug-in ID) and delete the entry of your plug-in. Make sure you delete the right plug-in, otherwise other plug-ins may not load anymore.

1 Like

Right again, sir. Thx

Happens to me all the time - by now I can dream the symptoms :smile: