algorithmic modeling for Rhino
Grasshopper.Instances.HideRemotePanel and ShowRemotePanel.
--
David Rutten
david@mcneel.com
Thanks
Private Sub RunScript(ByVal id As Guid)
Dim obj As IGH_DocumentObject = GrasshopperDocument.FindObject(id, True)
If (obj Is Nothing) Then ReturnDim rcpAware As IRcpAwareObject = TryCast(obj, IRcpAwareObject)
If (rcpAware Is Nothing) Then ReturnDim proxy As GUI.RemotePanel.IRcpItem = rcpAware.PublishRcpItem()
If (proxy Is Nothing) Then ReturnGrasshopper.Instances.ShowRemotePanel()
Dim container As GUI.RemotePanel.RcpGroup = GrasshopperDocument.RemotePanelLayout.EnsureGroup()
container.Expand()
container.AddItem(proxy)
GrasshopperDocument.RemotePanelLayout.OnLayoutChanged()
End Sub
This will add a new instance of a remote proxy to the panel each time the function is called though. If you don't want that you'll have to test whether it is already published first.
--
David Rutten
david@mcneel.com
I don't understand. You can add objects to a Grasshopper file in code, though doing so during a solution is frowned upon.
Are you sure that IDs is what you want to do though? It's pretty hard for a user to figure out what ID an object has.
--
David Rutten
david@mcneel.com
Ok I understand,
I must first integrate corresponding to the id to a solution to use the script parameter.
My goal is to integrate in a >RCPC a number of slider automatically according to a parameter.
For example, if I have N slider control for a one parameter setting to change my form then N slider will fit in the RCP.
N varies with another parameter eg number of ratings of a polygon.
I hope you understand better, my english is bad but getting better little by little.
I first try to reverse code, but apparently there is a visible trace in the RCP...
Private Sub RunScript(ByVal id As Guid, ByVal y As Object, ByVal OnOff As Object, ByRef A As Object)
If OnOff Then
Dim obj As IGH_DocumentObject = GrasshopperDocument.FindObject(id, True)If (obj Is Nothing) Then Return
Dim rcpAware As IRcpAwareObject = TryCast(obj, IRcpAwareObject)If (rcpAware Is Nothing) Then Return
Dim proxy As GUI.RemotePanel.IRcpItem = rcpAware.PublishRcpItem()If (proxy Is Nothing) Then Return
Grasshopper.Instances.ShowRemotePanel()Dim container As GUI.RemotePanel.RcpGroup = GrasshopperDocument.RemotePanelLayout.EnsureGroup()
container.Expand()
container.AddItem(proxy)GrasshopperDocument.RemotePanelLayout.OnLayoutChanged()
Else
Dim obj As IGH_DocumentObject = GrasshopperDocument.FindObject(id, True)If (obj Is Nothing) Then Return
Dim rcpAware As IRcpAwareObject = TryCast(obj, IRcpAwareObject)If (rcpAware Is Nothing) Then Return
Dim proxy As GUI.RemotePanel.IRcpItem = rcpAware.PublishRcpItem()If (proxy Is Nothing) Then Return
Grasshopper.Instances.ShowRemotePanel()Dim container As GUI.RemotePanel.RcpGroup = GrasshopperDocument.RemotePanelLayout.EnsureGroup()
container.OnDelete()
container.RemoveItem(proxy)GrasshopperDocument.RemotePanelLayout.OnLayoutChanged()
End If
End Sub
Result in RCP
PS:I have not managed to integrate the parameter to an existing group or a group that I chose the name.
This file...
The attached file clears the entire RCP layout and then re-adds all sliders in the order in which they appear in the document. If you want to retain the same order top-to-bottom, you'll have to sort them first.
--
David Rutten
david@mcneel.com
your code:
Dim container As GUI.RemotePanel.RcpGroup = GrasshopperDocument.RemotePanelLayout.EnsureGroup()
container.OnDelete()
container.RemoveItem(proxy)
EnsureGroup() basically makes sure that there is at least one container on the remove panel. If there isn't one, it'll make one, if there already are containers, it'll return the bottom most one. When you're removing items from an RCP layout, you do not want to start making new groups.
You have to iterate over all the existing groups, figure out which ones contain an RCP proxy that points to your slider, and remove those.
container.RemoveItem(proxy) will not work if you only just made that proxy anew. It has to already be part of the RCP panel.
Adding and removing proxies to and from the RCP panel is very similar to adding and removing controls to windows in winforms.
--
David Rutten
david@mcneel.com
If, for true values, I can create the "id" parameter in a group called "Params".
For false values I can read the "Params" group to remove the "id" parameter?
Dim container As GUI.RemotePanel.RcpGroup = GrasshopperDocument.RemotePanelLayout.EnsureGroup()
container.OnDelete()
container.RemoveItem(proxy)
I understand that this code is a mistake but should I use a read?
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by