mcneel / rhinocommon

RhinoCommon is the .NET SDK for Rhino5 / Grasshopper
http://wiki.mcneel.com/developer/rhinocommon
243 stars 93 forks source link

Rhino.UI.Panel Sample #118

Closed sbaer closed 12 years ago

sbaer commented 12 years ago

Need to create a simple "hello world" docking panel sample

AcOscar commented 12 years ago

Do you mean something like this?:

I found this at mcneel.com and extract this:

Protected Overrides Function OnLoad(ByRef errorMessage As String) As Rhino.PlugIns.LoadReturnCode
    'register it with rhino
    Rhino.UI.Panels.RegisterPanel(Me, GetType(UserControl1), "my PlugIn Control", My.Resources.Icon1)
    Return Rhino.PlugIns.LoadReturnCode.Success
End Function
Public Sub TooglePanel()
    If Rhino.UI.Panels.IsPanelVisible(UserControl1.GetGUID) Then
        Rhino.UI.Panels.ClosePanel(UserControl1.GetGUID)
    Else
        Rhino.UI.Panels.OpenPanel(UserControl1.GetGUID)
   End If
End Sub
    Imports System.Runtime.InteropServices
    <GuidAttribute("B444DE2F-F19F-4791-B90C-12F7F34F8A61")> _
    Public Class UserControl1
        Public Shared Function GetGUID() As Guid
            'thanks Steve for this little bit
            Dim id As Guid = GetType(UserControl1).GUID
            Return id
        End Function
    End Class

thats all, you have now a panel, to display you can do this manually in rhino or you can use your command class in your plugin:

Protected Overrides Function RunCommand(ByVal doc As RhinoDoc, ByVal mode As RunMode) As Result
    MyProject1PlugIn.Instance.TooglePanel()
    Return Result.Success
End Function

Best Holger Rasch

johnmorse commented 12 years ago

Sample added at https://github.com/mcneel/rhinocommon/tree/master/examples/PanelSamplePlugIn

CataIin123 commented 6 years ago

Hello, Is it possible to use a button to run a command ?

sbaer commented 6 years ago

@CataIin123 please use https://discourse.mcneel.com/ to ask Rhino plug-in questions