algorithmic modeling for Rhino
Hi all,
I'm trying to get my head around the correct implementation of Additional Component Menu Items.
I'm attempting to create a CreateDomain component that will have 2 additional menu options ("Swap" and "Reverse"), which can be toggled independently, so there are 4 possible combinations (both off, Swap on-Reverse off, Swap off-Reverse on, both on). This could result in only one 'settings' integer to be written/read. But I can't get this working as described (yet).
After all I've tried, I'm now at a complete loss. I've attached what I ended up with (messed it up, but may illustrate what I discribed above), I'm hoping someone can steer me in the right direction, or maybe even correct my messy script..:)
Tags:
I'd do it as follows:
Private _swap As Boolean
Private _reverse as Boolean
Protected Overrides Sub AppendAdditionalComponentMenuItems(ByVal menu As System.Windows.Forms.ToolStripDropDown)
Dim swapItem As ToolStripMenuItem = Menu_AppendItem(menu, "Swap", AddressOf Menu_SwapClicked, True, _swap)
Dim revItem As ToolStripMenuItem = Menu_AppendItem(menu, "Reverse", AddressOf Menu_ReverseClicked, True, _reverse)
swapItem.ToolTipText = "When checked, the domain bounds will be swapped"
revItem.ToolTipText = "When checked, the domain bounds will be reversed"
End Sub
Private Sub Menu_SwapClicked(ByVal sender As Object, ByVal e As EventArgs)
RecordUndoEvent("Swap")
_swap = Not _swap;
ExpireSolution(True)
End Sub
Private Sub Menu_ReverseClicked(ByVal sender As Object, ByVal e As EventArgs)
RecordUndoEvent("Reverse")
_reverse = Not _reverse;
ExpireSolution(True)
End Sub
--
David Rutten
david@mcneel.com
Thank you David! That fixed the tick functionality.
After some rewriting I think the only trick left is the Write and Read functionality, appearantly I got that wrong too: it doesn't remember it's correct state ~ I need some sleep - and some teaching:)
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