How to do not show inference points on the moving component itself?

sketchup

#1

I write a custom move tool.
When moving the component, the InputPont show the inference point itself.

custom_move_tool

But the builtin move tool don’t show the inference point itselt.

builtin_move_tool

how to do it?

The code is follow, Copy it and run in the bulitin ruby console:

class CustomMoveTool
  def onMouseMove(flags, x, y, view)
    @mouse_ip = view.inputpoint(x, y)
    if @mouse_ip.valid?
      # create component instance from builtin components
      if @component_instance.nil?
        model = Sketchup.active_model
        def_path = Sketchup.find_support_file 'Door Interior.skp', 'Components/Components Sampler'
        door_def = model.definitions.load def_path
        transform = Geom::Transformation.new
        @component_instance = model.entities.add_instance door_def, transform
      end
      # move door by mouse position
      transform = Geom::Transformation.new @mouse_ip.position
      @component_instance.move! transform
      view.tooltip = @mouse_ip.tooltip
      view.invalidate
    end
  end

  def draw(view)
    # display the mouse position uses inferencing
    # FIXME: Don't display inferencing point on the moving component
    @mouse_ip.draw(view) if @mouse_ip && @mouse_ip.display?
  end
end

Sketchup.active_model.select_tool CustomMoveTool.new

#2

This line, in the draw() method, draws the inputpoint …

@mouse_ip.draw(view) if @mouse_ip && @mouse_ip.display?

Comment it out and try again.


#3

@DanRathbun The View draw the inference point and tooltip by the InputPoint class.
If comment it out, no inference point is shown.
I need to show some inference points, but the moving component’s inference points are not included.
Is there any other solution?


#4

You call draw on every InputPoint instance individually.

  • If you want an InputPoint instance not to be drawn, just do not call draw on it.
  • If you want an input point to be drawn only under certain conditions (inputpoint’s instance_path contains the moved component instance), then add a condition around the call to draw.

#5

@Aerilius

certain conditions: inputpoint’s instance_path does not contain the moved component instance

I change the code and try again:

def draw(view)
  if @mouse_ip && @mouse_ip.display? && !@mouse_ip.instance_path.include?(@component_instance)
    @mouse_ip.draw(view)
    view.tooltip = @mouse_ip.tooltip
  end
end

As I do, I can feel that the inference system slower and clumsy.

I need a better solution:

  • When the component instance is being moved, the user can see the component, but the inference system can’t see the component instance.
  • When the component instance has been moved, neither the user nor the inference system can see the component instance.
  • Just like the built in move tool do.

Thank you all the same. :smile:


#6

That means that you don’t do view.inputpoint(...) when you don’t want the inference system to get an inference.

This sounds like your tool has several steps (states), and you would have much more ease with it if you think about the states and state transitions first (state machine).


#7

The API doesn’t expose any way for Sketchup::Inputpoint to ignore specific entities. But it sounds like a nice improvement.

You can log bugs and improvements in our issue tracker: https://github.com/SketchUp/api-issue-tracker/issues


#8

@Aerilius
Maybe I’m not explaining it very well. Let’s the complete code say:

  1. The CustomMoveTool use the inference engine, in order to find the inference point of the inference entity, and move the moving entity to the position of the inference point.

For example, we move the door to the start point of an edge:

term example
moving entity door
inference entity edge
inference point start point
  1. The @mouse_ip is the inference engine, it draw the inference point of the inference object.

  2. The @component_instance is moving entity, so the @mouse_ip don’t need to draw ** inference point** of the @component_instance, BUT HOW TO DO IT?


#9

@tt_su Log it on the issue tracker.

Is there a temporary solution?