sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    Pickray

    Scheduled Pinned Locked Moved Developers' Forum
    2 Posts 2 Posters 771 Views 2 Watching
    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.
    • A Offline
      ahjkuipers
      last edited by

      Hello to all,

      There's something I don't understand (no, many things) and that's about pickray.
      Suppose I have a model existing of a single edge. Then I create a ray from the eye through one of the two endpoints of the on screen projection and try to find the intersection of that ray with the edge. Why is the ray (a line) missing the edge? I'm totally confused because I presumed that the result had to be the startposition (or endposition, depending of the screencoordinates) of the edge.

      An example

      def exp_a
        mod = Sketchup.active_model
        view = mod.active_view
        ents = mod.entities
        ents.clear!
        edges = ents.add_edges([0, 0, 0] , [100, 100, 100]) 
        edge = edges[0]
        pt = view.screen_coords(edge.start.position)
        ray = view.pickray(pt.x, pt.y)
        Geom.intersect_line_line(edge.line, ray)
      end
      

      The result is nil.

      Can anybody tell me what is wrong with my assumption that in this case the result should be [0, 0, 0]? What is wrong with my understanding of pickray?

      1 Reply Last reply Reply Quote 0
      • thomthomT Offline
        thomthom
        last edited by

        Maybe due to precision issue?
        Not sure, but you don't have to convert between screenpoints like that:

        
          mod = Sketchup.active_model
          view = mod.active_view
          ents = mod.entities
          ents.clear!
          edges = ents.add_edges([0, 0, 0] , [100, 100, 100]) 
          edge = edges[0]
          pt1 = edge.start.position
          pt2 = view.camera.eye
          Geom.intersect_line_line(edge.line, [pt1, pt2])
        
        

        Thomas Thomassen — SketchUp Monkey & Coding addict
        List of my plugins and link to the CookieWare fund

        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