I’m using a GetPoint with multiple DoubleOptions, and I would like to change values using shortcuts.
I was checking KeyboardEvent, and I can catch the keys, but is there a way to don’t propagate it? If not, I can create my own keyboard hook.
Another question, is there a way to change the value of a Double option by code while is in execution? I change the value, but the command prompt still shows the original value.
Do you mean you want to change the parts that get underlined automatically by the rhino command-line?
The shortcuts w, l and h are automatically generated, these can’t be overridden as far as I know. When you change a value and accept that the command-prompt should automatically update.
Is there a reason why you want to user shortcuts different from what the command-line gives you?
Yes, but I want to increase/decrease the values by pressing a key. For example, increase the Width value 0.1 pressing key one key, and decrease it with another key. Does it make sense? I think it is too slow for artistic designs to change manually.
I see what you are trying to do. At the moment I don’t think there is a way to do that such that the prompt updates properly, other than maybe posting the correct combination of keypresses you want to happen on your shortkey. In the case I showed above that’d be wenter15enter. Not sure how to do that in a good way though. Sounds like a lot of hackery will be involved.
I wanted to do the same thing a long time ago, but my coding skills were by far not good enough back then and I haven’t tried since then, but had the exact same goal in mind. the plan was the following:
combine the preview thingy I posted earlier together with this code:
Call TestGetKey()
Sub TestGetKey
Dim key
Dim strUpSrf
Dim arrPtOnSrf
strUpSrf = rhino.GetObject("select UpSrf", 8)
While Not IsNull(key)
key = Rhino.GetKey("Press a key")
If Not isNull(key) Then
If key(0) = "81" Then '---Q---
msgbox("-SIZE/---Q---")
End If
If key(0) = "87" Then '---W---
msgbox("MOVE UP/---W---")
End If
If key(0) = "69" Then '---E---
msgbox("+SIZE/---E---")
End If
If key(0) = "65" Then '---A---
msgbox("TURN LEFT/ ---A---")
End If
If key(0) = "83" Then '---S---
msgbox("MOVE DOWN/---S---")
End If
If key(0) = "68" Then '---D---
msgbox("TURN RIGHT/---D---")
End If
' If key(0) = "13" Then '---Enter---
' msgbox("Enter")
' End If
'
Else
Dim arrCursor
arrCursor = Rhino.GetCursorPos
Rhino.AddPoint(arrCursor(0))
msgbox("---LMC---")
End If
Wend
End Sub
(which I am not sure still works)
Rather than picking a ‘point on the surface to orient to’ using a stock GetPoint object, try creating a new class that inherits from GetPoint . In the new class you can construct the keyboard handler class, and have it post messages to that class.
For an example of how to inherit a new class from GetPoint , see the following developer sample.
If I remember correctly, back in the Matrix 5.0 days they had the exact function like this for orienting gems on surfaces pretty dynamically, but it would it was made with help of an external exe file.
hope this helps in case you decide to hack it together.