Get selected render material

Is there any way to get the selected material (from the materials panel GUI) programmatically?


I am able to get the panel object using its guid but that doesnt expose any property referencing the selected material in the GUI.

It depends. At least if your implementation is part of the editor and you have implemented your own section. That section knows the selection. However I think you want the selection in a more general way?

Hi @maxsoder , thanks for getting back.
I am not implementing my own panel in this case.

I am using the materials panel with Panel.GetPanel(guid, rhinoDoc)
https://developer.rhino3d.com/api/rhinocommon/rhino.ui.panels/getpanel#(guid,rhinodoc)
but the returned panel is not exposing any properties or functions i can use to get the selected material.
Any thoughts?

Cheers

Currently there is no public API to get the editors selected content. We could probably add one.

@maxsoder I understand. would love to know when/if this access gets added…

I am trying to create a paint bucket command / tool for Rhino.
The goal is to select a material from Materials or RenderLibraries Panel > Run the command > select entire objects or subelements to apply the selected material on click.

Currently when I run the command, it pops up a window to select a material (sourced from rendermaterial table) but it would be ideal to retrieve the selected material from one of the built-in panels.

1 Like

I see. I have to discuss this with others to find out where the best place would be to add the API or if there is another way to do it. I will get back to this when I get more information.

1 Like

Thanks @maxsoder

I discussed the issue and I made a YT for it RH-84443 Need an API to get the content editor selection.

Thanks @maxsoder , much appreciated!

I tried clicking on the YT link in your reply but got a 404 page.
Keen to know when the API is implemented. Cheers

I changed the permission of the YT. It should be now visible.

1 Like

There is a problem with getting the selection from the content editor. The problem is that there can be many editors open so one would have to know which editor the user is looking at.

I think the correct solution should be that the user starts the command. The command would open a dialog to choose a content. A dialog with the thumbnail view. The user selects the content and the command continues to do its next thing.

Thanks for getting back @maxsoder
I have implemented something similar. Will stick with it.
Cheers

RH-84443 is fixed in Rhino 8 Service Release 15

Is there any documentation or sample code for the newly added API?
RH-84443

There is a new function public static bool ShowContentInstanceBrowser(RhinoDoc doc, ref Guid uuidInstanceInOut, RenderContentKind kind, ContentInstanceBrowserButtons buttons)

I was going through RhinoCommon documentation but couldnt find any method named this^

Thanks again.

It might be that the documentation has not yet produced the summary for the function.

Here is the summary for the function

    /// <summary>
    /// Allows the user to choose a content by displaying the Content Instance Browser dialog.
    /// The dialog will have OK, Cancel and Help buttons, and optional New and Edit buttons.
    /// <param name="doc">Specifies the document to use.</param>
    /// <param name="instance_id">Sets the initially selected content and receives the instance id of the chosen content.</param>
    /// <param name="kinds">Specifies the kind(s) of content that should be displayed in the browser.</param>
    /// <param name="buttons">Specifies which optional buttons to display.</param>
    /// Returns true if the user chooses a content or false if the dialog is cancelled.
    /// </summary>
1 Like

Thanks again

1 Like