Cannot enable VCB by enableVCB?

Dear Friends,
I used following code

      def enableVCB?
        return true

Also when I call it answer is true but when I write a number VCB value don’t change just its background color change to yellow. 1- Can you help me to solve this problem? 2- How can I read number from VCB value? 3-Can you send me linetool.rb if legal?

This is a Tool callback method that the SketchUp engine calls when a Ruby Tool is active.

You or your code never call it directly.

Your code can only read VCB text from within an active Tool.

Your tool must define a #onUserText callback method.

1 Like

#onUserTest work’s well, but my first problem exist. My codes is similar to “line tool”. In my software I use " Sketchup.vcb_value = ll". it work’s well but when I type a number, it cannot show on vcb. In line tool vcb shows length but when we type a number, vcb shows number. Can you help me for this problem?

I explained it, so apparently not.

ALSO … you have not posted any code that I could see what is wrong !

No. It is posted in the official extension tutorials. Go get it yourself.

To show my problem I wrote following simple code.

# encoding: UTF-8
#{ =========================================================
#  Documentation block ...
#} =========================================================

require 'sketchup.rb'
module MajidMahmoudi
  module MajWallTest
    class MajWall
      def init() 
        @input =
        @pt = [@input.position]
        @pt[0] = @input.position
        @pt[1] = @input.position
        @distance = 0.0
      def activate 
      end #activate

      def onMouseMove(flags, x, y, view)
        @input.pick view, x, y
        @pt[1] = @input.position
        if @distance != 0
          p "Distance = #{@distance * 2.54}"
          @distance = 0
      def onUserText(text, view)
        @distance = text.to_l
        Sketchup.vcb_value = @distance
        rescue ArgumentError
        view.tooltop = 'Invalid length'
      def draw view
        if @input.valid?
          ll = @pt[0].distance(@pt[1])
          view.line_width = 3
          view.draw_polyline @pt[0], @pt[1]
          Sketchup.vcb_value = ll  
        end # if
      end # draw
    end #class Wall
#    unless file_loaded?(__FILE__)"Plugins").add_item("MajWall") {
#      file_loaded(__FILE__)
#    end  
  end #MajWallTest
end #MajidMahmoudi

If you write a number then enter, you can see it n console but cannot see in vcb.

It seems to work okay for me. (If you move the mouse it wipes out what your code put into the VCB.)

Except that it does not honor the user’s model units. I typed 80 ENTER and the VCB showed 80.0000" (inches) but the Console said 203.2 ?

You also need a view.invalidate call in a deactivate method so that the view is cleared when another tool is activated.

It is traditional to use blue color for rubber banding in virtual tool draws.

1 Like

Your SU unit is Inch and mine is cm. I changed unit. Thank you for your help.

For people whom have same problem. I used “Sketchup.vcb_value = ll” in (def draw view) and it makes this problem for me. After I move it to (def onMouseMove(flags, x, y, view)) my problem solved.

1 Like