# Get the inner and outer boundary coordinates of the surface

**URL:** <https://forums.sketchup.com/t/get-the-inner-and-outer-boundary-coordinates-of-the-surface/164318>\
**Category:** Ruby API\
**Tags:** sketchup\
**Created:** [May 11, 2021, 2:10pm UTC](https://forums.sketchup.com/t/get-the-inner-and-outer-boundary-coordinates-of-the-surface/164318 "2021-05-11T14:10:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![skyfire](https://avatars.discourse-cdn.com/v4/letter/s/6a8cbe/32.png) [@skyfire](https://forums.sketchup.com/u/skyfire)\
**Post date:** [May 11, 2021, 2:10pm UTC](https://forums.sketchup.com/t/get-the-inner-and-outer-boundary-coordinates-of-the-surface/164318/1 "2021-05-11T14:10:05Z")

</div>

As shown in the picture, this is a three-dimensional terrain, which consists of countless triangles. Now I want to process this piece of terrain, not only need to obtain the coordinates of each plane triangle, but also to obtain the boundary coordinates of the outermost circle of the entire surface, what should I do?

 ![5c4406b4e69791f0f0338f70d0d0912](https://global.discourse-cdn.com/sketchup/original/3X/1/a/1a8411302f2f974a79840fff7120607cb00e5d0d.png)

---

<div class="post-metadata">

**Author:** ![DanRathbun](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/danrathbun/32/500_2.png) [@DanRathbun](https://forums.sketchup.com/u/DanRathbun)\
**Post date:** [May 11, 2021, 3:32pm UTC](https://forums.sketchup.com/t/get-the-inner-and-outer-boundary-coordinates-of-the-surface/164318/2 "2021-05-11T15:32:54Z")

</div>

I think this has been asked already. Have you searched this category ?

@skyfire Jason, you also participated in the following topic …

- [How to get outer points of a curved terrain?](https://forums.sketchup.com/t/how-to-get-outer-points-of-a-curved-terrain/151438)

If you found no older topic thread, then look at the surface above, and think what is **different** about the edges that are along the border ?

---

<div class="post-metadata">

**Author:** ![dezmo](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/dezmo/32/51058_2.png) [@dezmo](https://forums.sketchup.com/u/dezmo)\
**Post date:** [May 11, 2021, 4:32pm UTC](https://forums.sketchup.com/t/get-the-inner-and-outer-boundary-coordinates-of-the-surface/164318/3 "2021-05-11T16:32:22Z")

</div>

My “usual” dirty…

```ruby
# Assuming the terrain is consist of a raw geometry 
# and selected
def get_triangles_bound_vertex_of_terr
  model = Sketchup.active_model
  sel = model.selection
  faces = sel.grep(Sketchup::Face)
  triangles_pts = faces.map{|f| f.vertices.map(&:position)}
  p "Triangles, point trios: #{triangles_pts}" 
  # could be other polygon as well
  
  all_edges = sel.grep(Sketchup::Edge)
  bound_edges = all_edges.find_all{|edge| edge.faces.size == 1}
  bound_vertice_pairs = bound_edges.map{|e| e.vertices.map(&:position)}
  p "Boundary, point pairs: #{bound_vertice_pairs}"
  sel.clear
  sel.add(bound_edges)
end
get_triangles_bound_vertex_of_terr

```

---

<div class="post-metadata">

**Author:** ![Aerilius](https://avatars.discourse-cdn.com/v4/letter/a/e19b73/32.png) [@Aerilius](https://forums.sketchup.com/u/Aerilius)\
**Post date:** [May 11, 2021, 6:00pm UTC](https://forums.sketchup.com/t/get-the-inner-and-outer-boundary-coordinates-of-the-surface/164318/4 "2021-05-11T18:00:29Z")

</div>

You may also want the point coordinates in **sorted** order if you want to reconstruct boundary edges or visualize (or export them):

> [@How to get outer points of a curved terrain?](https://forums.sketchup.com/t/how-to-get-outer-points-of-a-curved-terrain/151438/17):
>
> Something like this should work for 2018 def outer\_edges sel = Sketchup.active\_model.selection edges = sel.grep(Sketchup::Edge) edges.find\_all { |edge| edge.faces.one? { |face| sel.include?(face) } } end def sort\_points(edges) last\_edge = edges.pop sorted = [last\_edge] for i in (0..(edges.count - 1)) do last\_edge = edges.find do |edge| edge.start.position == last\_edge.start.position || edge.start.position == last\_edge.end.position || edge.end.position …

---

<div class="post-metadata">

**Author:** ![DanRathbun](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/danrathbun/32/500_2.png) [@DanRathbun](https://forums.sketchup.com/u/DanRathbun)\
**Post date:** [May 11, 2021, 11:53pm UTC](https://forums.sketchup.com/t/get-the-inner-and-outer-boundary-coordinates-of-the-surface/164318/5 "2021-05-11T23:53:43Z")

</div>

There’s an echo in here … in here …
