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

Finding start and end point of a component

Scheduled Pinned Locked Moved Developers' Forum
4 Posts 3 Posters 97 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.
  • D Offline
    Davidfi1
    last edited by 8 Feb 2013, 14:52

    I need to find the two points of the top line inside an instance of a component.
    At first it looked like an easy task, but when I tried actually doing it,
    I found out it is not that easy.
    sampleTest
    I need to run a ruby script and get the [x,y,z] of the points that are measured.

    can you help pleas?

    Thank you.

    1 Reply Last reply Reply Quote 0
    • T Offline
      thomthom
      last edited by 8 Feb 2013, 15:24

      Would need more context to how to you want to determine these points.

      Is the object always this configuration?

      Is it based on what vertices have dimension objects attached?

      Are you trying to make a custom tool to pick the points?

      A use-case would be good because the question is currently to ambiguous with too many possible answers.

      Also, what have you tried?

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

      1 Reply Last reply Reply Quote 0
      • T Offline
        TIG Moderator
        last edited by 8 Feb 2013, 17:08

        The component instance has a boundingbox - see the API docs.
        bb=obj.bounds
        From that you can find its 8 corners.
        You can also find things like its min/max/center.
        So for example you can find the two points that define one bottom-end edge, find the point mid-way between them, and change its z.value to bb.max.z.
        You can repeat this for the other end's vertices.
        Then you have two Point3d references with the needed XYZ ?

        BUT if for example this 'ridge' is not central or perhaps it's even not level, and you want to find its end points 'in the model' then an alternative is to find all edges in the edges=instance.definition.entities.grep(Sketchup::Edge), then sort through their vertex points for the two highest... and those are then the two points you need [almost] - let's call them pt1 and pt2. Find the 'transormation'... tr=instance.transformation and then apply that to the two points ( pt1.transform!(tr) and pt2.transform!(tr)) and they will then be the points you want to get the XYZ from...

        TIG

        1 Reply Last reply Reply Quote 0
        • D Offline
          Davidfi1
          last edited by 8 Feb 2013, 21:05

          This
          @tig said:

          (pt1.transform!(tr) and pt2.transform!(tr))

          worked very nicely.

          Thank you.

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

          Advertisement