• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Detecting/selecting a temporary Drawing

Scheduled Pinned Locked Moved Developers' Forum
2 Posts 2 Posters 2.9k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    penpendrum
    last edited by 1 Mar 2018, 02:05

    I want to make a sketchup tool.. I wanted it to select a temporary drawing like it will change color when I select or hover my mouse on it ..
    can anyone give me a head start on how to do it

    I have done a lot of google search but i just cant seem to pin point what kind of term fits it

    what i need is :
    1.) to detect and change the color of the temporary drawing square in the "def draw" everytime i hover and select it
    2.) to detect and change the color of the temporary corner of the square in the "def draw " everytime i hover and select it

    please examine my code below

    class MyTool

    def initialize
      
    end
    
    
    def activate
    
        @mouse_ip = Sketchup::InputPoint.new
        @picked_first_ip = Sketchup::InputPoint.new
    
     
        
    end
    
    def draw(view)
      @mouse_ip.draw(view) if @mouse_ip.display?
      
      
      # Draw a square.
    

    points = [
    Geom::Point3d.new(0, 0, 0),
    Geom::Point3d.new(9, 0, 0),
    Geom::Point3d.new(9, 9, 0),
    Geom::Point3d.new(0, 9, 0)
    ]

    Fill

    view.drawing_color = Sketchup::Color.new(255, 128, 128)
    view.draw(GL_QUADS, points)

    Outline

    view.line_stipple = '' # Solid line
    view.drawing_color = Sketchup::Color.new(64, 0, 0)
    view.draw(GL_LINE_LOOP, points)

    end
    
    def onLButtonDown(flags,x,y,view)
      puts "yout tool has clicked"
       
    end
    
    def onLButtonUp(flags,x,y,view)
      puts "yout tool has clicked"
      puts  
        
    end
    
    def onMouseMove(flags, x, y, view)
    
        if picked_first_point?
          
          @mouse_ip.pick(view, x, y, @picked_first_ip)
          puts "point A"
        else
         
          
        @mouse_ip.pick(view, x, y)
          
        end
       
        if @mouse_ip.valid?
        view.tooltip = @mouse_ip.tooltip 
        
        
        end
        
        starting_point = Geom::Point3d.new(9, 0, 0)
        ip2 = Sketchup::InputPoint.new(starting_point)
       view.inputPoint(x,y,ip2)
        
        view.invalidate
    end
    
    def picked_first_point?
        @picked_first_ip.valid?
      end
    
    def getBoundingBox(corner)
      model= Sketchup.active_model
      selection = model.selection
      
      return selection[0].bounds.corner(corner)
    end
    
    def resume(view)
      view.refresh
    end
    

    end

    my_tool = MyTool.new

    Sketchup.active_model.select_tool(my_tool)

    1 Reply Last reply Reply Quote 0
    • D Offline
      Dan Rathbun
      last edited by 15 Mar 2018, 16:04

      No one will attempt to even read you code until it is properly formatted within [ code ] ... [ /code ] tags.

      There is a button on the post edit toolbar to insert these tag sets, or highlight a bunch of text and click the button to wrap the text in these tags.

      I'm not here much anymore.

      1 Reply Last reply Reply Quote 0
      • 1 / 1
      • First post
        Last post
      Buy SketchPlus
      Buy SUbD
      Buy WrapR
      Buy eBook
      Buy Modelur
      Buy Vertex Tools
      Buy SketchCuisine
      Buy FormFonts

      Advertisement