Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question
3

How to get the SketchUp Edges of a Surface?

asked 2015-07-22 13:46:47 -0500

updated 2015-07-22 15:09:23 -0500

I'm trying to implement a way to calculate thermal bridges in the ground surfaces and the only thing that is missing is that I need to get the Edges. I can get the Point3d but the thing I really like to have access to is the SketchUp's own entities of the OpenStudio model which in this case is the Edges. So how does one do this. How to get the matching entity of an OpenStudio model?

edit retag flag offensive close merge delete

Comments

comment cancelled

OS-user-AT's avatar OS-user-AT  ( 2015-07-22 14:59:03 -0500 )edit

What do you need in an edge beyond the two endpoints?

__AmirRoth__'s avatar __AmirRoth__  ( 2015-07-22 16:04:13 -0500 )edit

@AmirRoth: I need to give them properties like first of all an ID like the normal IDF object Handles and also I need to know which surfaces includes the edge and several other stuff. I can of course do this on my own but if there be a chance to use the Edges my life will be a lot easier

Pouya Kary's avatar Pouya Kary  ( 2015-07-22 16:29:36 -0500 )edit

I think you will need to roll this on your own.

__AmirRoth__'s avatar __AmirRoth__  ( 2015-07-22 16:53:31 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2015-07-22 17:44:09 -0500

updated 2015-07-22 19:03:45 -0500

here is a link to SketchUp API for faces. If you can. Get the SketchUp face for an OpenStudio surface then you can call face.edges.

I have a ruby method native to OpenStudio that I made to get the perimeter of a building. I made fake edges to accomplish that. I'll add that method to this answer later tonight.

# currently takes in model and checks for edges shared by a ground exposed floor and exterior exposed wall. Later could be updated for a specific story independent of floor boundary condition.

def OsLib_Geometry.calculate_perimeter(model)
 perimeter = 0
 model.getSpaces.each do |space|
   # counter to use later
   edge_hash = {}
   edge_counter = 0
   space.surfaces.each do |surface|
     # get vertices
     vertex_hash = {}
     vertex_counter = 0
     surface.vertices.each do |vertex|
       vertex_counter += 1
       vertex_hash[vertex_counter] = [vertex.x,vertex.y,vertex.z]
     end
     # make edges
     counter = 0
     vertex_hash.each do |k,v|
       edge_counter += 1
       counter += 1
       if vertex_hash.size != counter
         edge_hash[edge_counter] = [v,vertex_hash[counter+1],surface,surface.outsideBoundaryCondition,surface.surfaceType]
       else # different code for wrap around vertex
         edge_hash[edge_counter] = [v,vertex_hash[1],surface,surface.outsideBoundaryCondition,surface.surfaceType]
       end
     end
   end
   # check edges for matches (need opposite vertices and proper boundary conditions)
   edge_hash.each do |k1,v1|
     next if v1[3] != "Ground" # skip if not ground exposed floor
     next if v1[4] != "Floor"
     edge_hash.each do |k2,v2|
       next if v2[3] != "Outdoors" # skip if not exterior exposed wall (todo - update to handle basement)
       next if v2[4] != "Wall"
       # see if edges have same geometry
       next if not v1[0] == v2[1] # next if not same geometry reversed
       next if not v1[1] == v2[0]
       point_one = OpenStudio::Point3d.new(v1[0][0],v1[0][1],v1[0][2])
       point_two = OpenStudio::Point3d.new(v1[1][0],v1[1][1],v1[1][2])
       length = OpenStudio::Vector3d.new(point_one - point_two).length
       perimeter += length
     end
   end
 end
 return perimeter
end
edit flag offensive delete link more

Comments

1

This only works in SketchUp and I do not recommend anyone do this but you can get to the SketchUp entity for an OpenStudio model object like this:

OpenStudio::Plugin.model_manager.model_interface.openstudio_model.getSurfaces[0].drawing_interface.entity

Once again, this is not part of the OpenStudio API and will not work in measures. I would like to add an API for edges to the real OpenStudio API at some time in the future.

macumber's avatar macumber  ( 2015-07-22 18:18:36 -0500 )edit

@david-goldwasser Thanks a lot. That was a good! Actually I may use some of the lines!

Pouya Kary's avatar Pouya Kary  ( 2015-07-23 08:12:36 -0500 )edit

@macumber Thanks, That was exactly what I wanted. And what I'm writing is not a measure but more off a plugin that uses the OpenStudio model so that the user don't need to model the building from scratch so this is not a problem here. However thanks a lot!

Pouya Kary's avatar Pouya Kary  ( 2015-07-23 08:16:29 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Training Workshops

Careers

Question Tools

1 follower

Stats

Asked: 2015-07-22 13:46:47 -0500

Seen: 592 times

Last updated: Jul 22 '15