Have you looked at the example tool I just recently posted (6 days ago) in this forum ?
It traps SHIFT and CTRL modifiers to mouse button clicks in order to add or subtract from a selection set.
Use version 2 âŚ
[Example] A simple FaceSniffer tool extension - #2 by DanRathbun
In your case instead of looking for mouse clicks in onLButtonUp
, youâll have case
clauses in onKeyUp
that test for VK_UP
, VK_DOWN
, etc., to set set an internal instance variable that would hold a vector along which youâll draw an edge.
For example âŚ
case key
when VK_UP
@vec = Y_AXIS
when VK_DOWN
@vec = Y_AXIS.reverse
when VK_RIGHT
@vec = X_AXIS
when VK_LEFT
@vec = X_AXIS.reverse
else
# ignore key ?
end
And youâll use the onUserText
callback to receive user input from the VCB (aka Measurements input control. âVCBâ is an acronym for Value Control Box.)
But to begin with, the toolâs initial state must get an Inputpoint
from the user to know where to begin to draw from.
Basically your idea is a variation on a standard Edge drawing tool (ie, âLineToolâ).
Trimble has posted an example and tutorial Line Tool. (The tutorials have verbose comments. The examples have little or no commentary, but the code is the same.)
If you do not know how to use GitHub to create a fork etc., then you can simply copy the two files and paste them into your code editor. At GitHub, display the files (each in turn) and on the file toolbar at the right, between the edit (pencil) button and the delete (trash can) button, is the copy button (one page overlapping another.) Use the copy button to copy each file to the clipboard memory and then switch to your code editor and paste it in (CTRL+V).
Make sure to keep the same file and folder structure. The extension registrar file is at the top level (eventually in the âPluginsâ folder,) and the âmain.rbâ file goes into a subfolder that must be the same name as the registrar file.
You can rename the folder and registrar file to some thing like ânickcrush_linetool.rbâ and the folder to "ânickcrush_linetoolâ, but also change the top module to âNickCrushâ and the submodule to âLineToolâ in each file. Then, in the registrar file, edit the fields of the SketchupExtension
object and the comments at the top to reflect your modifications.
Usually we ask such postings be posted in the Commerical and Collaborative Work category.
I am not interested as the feature your talking about is already available in the native Line Tool.
After activating the tool, simply click a point in the model, then one of the LEFT or RIGHT arrow keys to lock an axis inference, then type a value and hit ENTER. The pencil cursor will remain at the start point, so the direction along either axis locked will be controlled by either a positive of negative value. Positive away from the start point, negative towards the start point.