sketchucation logo sketchucation
    • Login
    Oops, your profile's looking a bit empty! To help us tailor your experience, please fill in key details like your SketchUp version, skill level, operating system, and more. Update and save your info on your profile page today!
    🛣️ Road Profile Builder | Generate roads, curbs and pavements easily Download

    Drawing a ray or line from a vector

    Scheduled Pinned Locked Moved Developers' Forum
    3 Posts 3 Posters 433 Views 3 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.
    • J Offline
      jach9009
      last edited by

      I am currently retrieving a vector from sketchup and I am trying to draw a line from that retrieved vector. Is there a way to do this?

      1 Reply Last reply Reply Quote 0
      • M Offline
        mptak
        last edited by

        http://www.sketchup.com/intl/en/developer/docs/ourdoc/entities.php#add_cline

        This will give you a construction line defined by a point and a vector. If you want to draw a line segment aka edge you could get the second end point by applying a scaled transformation to your initial point.

        1 Reply Last reply Reply Quote 0
        • TIGT Offline
          TIG Moderator
          last edited by

          A vector defines a 'direction', which essentially is not determined in its location in space.
          To define an 'edge' you need a start point - let's call it 'point1'...
          Then set your vector's length using:
          vector.length=length
          and find 'point2' for the end point:
          point2=point1.offset(vector)
          Now you have two points representing the start/end-points of a potential new edge.
          Use
          Sketchup.active_model.active_entities.add_line(point1, point2)
          or
          Sketchup.active_model.active_entities.add_edges([point1, point2])

          Don't confuse edge & line - confusing the API does when adding one edge it calls it a 'line'!
          Actually a 'line' is a special geometrical construct of [point, vector], which us infinitely long passing through the point, along the vector. Lines can intersect etc...

          TIG

          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