Grasshopper

algorithmic modeling for Rhino

Hi all,

It' is possible to activate remote control panel with VB component.

I would like use a Boolean for activate RCP.

Views: 2394

Replies to This Discussion

Grasshopper.Instances.HideRemotePanel and ShowRemotePanel.

--

David Rutten

david@mcneel.com

Thanks

David,

In the same example, it is possible to add Remote Control items via VB components?


For example:
Through the id of a slider, add the slider in the RCP and in a group selects a parameter.

Thanks for all.

Private Sub RunScript(ByVal id As Guid)
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()
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

Thanks David,

I will try to inspire me the code to build another. is it possible to generate an id parameter in a code?

My problem is that if the parameter does not exist it can not be to integrate RCP. But I do not know if it is possible to introduce a parameter in an open instance.

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...

Attachments:

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

Attachments:

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?

RSS

About

Translate

Search

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service