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

Revision history [back]

To project the PV (or whatever) surface along a base surface nromal regardless of the surface's tilt/orientation (which is How It Should Be Done), do something like this:

  # get the base surface normal (vector)
  vec = surface.outwardNormal
  vec.setLength(0.0254) # PV/shading/whatever surface projection (m)

  # get window points and project along window normal
  vertices = surface.vertices
  transform = OpenStudio::Transformation.new
  transform = surface.space.get.transformation if surface.space.is_initialized

  # transform to world coords
  vertices = transform * vertices

  points = []
  vertices.each do |f|
    if debug_mode
      runner.registerInfo("window vertex: #{f}, projected PV vertex: #{f + vec}")
    end
    pp = f + vec
    points << pp
  end

  points = transform.inverse * points # send back to space coords

  # Make the new PV/shading/whatever surface
  shading_surface = OpenStudio::Model::ShadingSurface.new(points, model)

To project the PV (or whatever) surface along a base surface nromal regardless of the surface's tilt/orientation (which is How It Should Be Done), do something like this:

  # get the base surface normal (vector)
  vec = surface.outwardNormal
  vec.setLength(0.0254) # PV/shading/whatever surface projection (m)

  # get window points and project along window normal
  vertices = surface.vertices
  transform = OpenStudio::Transformation.new
  transform = surface.space.get.transformation if surface.space.is_initialized

  # transform to world coords
  vertices = transform * vertices

  points = []
  vertices.each do |f|
    if debug_mode
      runner.registerInfo("window vertex: #{f}, projected PV vertex: #{f + vec}")
    end
    pp = f + vec
    points << pp
  end

  points = transform.inverse * points # send back to space coords

  # Make the new PV/shading/whatever surface
  shading_surface = OpenStudio::Model::ShadingSurface.new(points, model)

To project the PV (or whatever) surface along a base surface nromal normal regardless of the surface's tilt/orientation (which is How It Should Be Done), do something like this:

  # get the base surface normal (vector)
  vec = surface.outwardNormal
  vec.setLength(0.0254) # PV/shading/whatever surface projection (m)

  # get window points and project along window normal
  vertices = surface.vertices
  transform = OpenStudio::Transformation.new
  transform = surface.space.get.transformation if surface.space.is_initialized

  # transform to world coords
  vertices = transform * vertices

  points = []
  vertices.each do |f|
    pp = f + vec
    points << pp
  end

  points = transform.inverse * points # send back to space coords

  # Make the new PV/shading/whatever surface
  shading_surface = OpenStudio::Model::ShadingSurface.new(points, model)