Property panel with c#

Hi to all

Well I am going to update a plugin written in c++ but I want to split it in 2 parts

  1. All the heavy math stuff inside a c++ 64 bit plugin
  2. interface stuff in a c# plugin

Since I am a newbie in c# and have no idea on where to start to add a Property panel in rhinoui
does anybody have a code snippet of a property panel to share ?

or at least point me on how to create one ?
I have searched for the code examples in the rhinocommon but nothing related to UI and interfaces

gerry

Hi Gerry,

If you are looking to create a docking panel, see the following examples:


https://github.com/dalefugier/SampleCsPanel

If you are looking for something else, let me know.

– Dale

If you are new to c# and looking for the actual control for a “property panel” style control (assuming you are using WinForms) you’ll want to check out the PropertyGrid in the Controls ToolBox when you are making your form (it may not show up under the Common Controls section, but shows up under All Windows Forms). I’m quite fond of them, and have used them in my own Rhino Docking Panels. You end up writing a lot of wrapper “Properties”, but for me it’s less overhead and headache than having to code 30 edit boxes…

HTH,
tom

Dale & Tom

This is what I was searching for

Thanks a lot

gerry

Hi All,

Thanks in advance for any help. I’ve been looking with no success about how to develop a panel with a “dynamic” update based on user selection in Rhino.

At present the data is stored as usertext, and I’d like to be able to “disable” the displayed value if it differs when multiple objects are selected. Something like the display color. If the sample also showed a pick list like this, it would be great.

Thanks again

Jon

Hi Jon,

If I understand correctly, you want to enable or disable items on the Properties page (panel) depending on what is selected. This is not possible using any Rhino SDK.

You can, though, add custom pages to the Properties panel. The Material, Texture Mapping, and Detail pages (shown in your image) are examples of this.

Does this answer your question?

Hi Dale,

Hope you’re well.

Yes, adding custom pages to the properties panel sounds like what I would like.
Are there any samples (or pointers) demonstrating this?

Thanks,

Jon

I’m assuming this is relevant?

Is this working in Rhino WIP? I also assume this isn’t available in dotnet for v5.

Thanks,

Jon

Hi Jon,

Sorry for the delay - here is a simple example.

https://github.com/dalefugier/SampleCsObjectProperties

Let me know if you have questions.

Hi Dale,

This is great (sorry, I didn’t spot the reply earlier and if I got a notification I didn’t recognize it).

I’ll take a look further at implementing this.
Now I just need to think the logistics of how to support this as I’m assuming many of my users are still on RC0 of v5.

I’ll be back if I have further questions.

Cheers,

Jon

For anyone looking to still build against an older rhcommon dll but support this, I found using reflection I could invoke the SelectedObjects property using this code in the SampleCsObjectPropertiesPage class

RhinoObject[] robjs = this.GetType().GetProperty(“SelectedObjects”).GetValue(this, null) as RhinoObject[];
foreach (RhinoObject rh_obj in robjs)

1 Like

If your plug-in references Rhino 5 SRx, then your customers will be required to be using Rhino 5 SRx or greater to use your plug-in.

Building against the latest Rhino SR is a good way to make sure your customers are up-to-date.

Does this help?

Hi Dale,

Thanks for the reply. In an ideal world, yes I would only build against latest release. But I have some clients who never move from SR0. Not necessarily the end users, but typically the IT support in charge of deployments (usually in large firms). Users don’t have admin permissions on their computer. Whilst it should be obvious that fixes and improvements are there to be gained, it’s not as easy as observing that. So if I try to enforce latest build I’m going to loose clients and users. I actually only recently stopped supporting v4.0 (although I was enforcing a service release on this, v4SR0 was too many years ago).

This isn’t necessarily a problem for me, this is the first time where I’ve found a property in a new release that I really wanted to use. Especially given that it seems it’s only one property, Using reflection I’ll be able to disable the panel on incompatible installations, and support the feature in those that do.

Far from ideal, but it’s a real situation.

Appreciate your help and support a lot,

Jon

Hi Dale,

(I hope I’m at the right place for my question :] )

In your helpfull plugin sample “SampleCsObjectProperties” you’re displaying the radius of a circle in an custom property panel.

Would it be for example possible, as the panel close (i.e. when the object is deselected), to store the displayed radius as the object name itself?

The final goal would to be able to display/modify custom objects UserText’s from a custom Panel. I’m quite a newbie in C# programming, I already (& roughly) achieved to display a UserText value, but I don’t get how to update it as the panel close.

    public override void InitializeControls(RhinoObject rhObj)
        {
            foreach (var rh_obj in SelectedObjects)
            {
                if (null != rh_obj)
                {
                    if (null != rh_obj.Attributes.GetUserStrings())
                    {
                        Rhino.RhinoApp.WriteLine(rh_obj.Attributes.GetUserString("SampleUserStrKey").ToString());
                    }
                    break;
                }
            }
        }

Many thanks in advance!