NREL / OpenStudio

OpenStudio is a cross-platform collection of software tools to support whole building energy modeling using EnergyPlus and advanced daylight analysis using Radiance.
https://www.openstudio.net/
Other
505 stars 192 forks source link

Wrong gbXML import #4809

Closed nickger closed 1 year ago

nickger commented 1 year ago

Issue overview

During import of gbXML geometry a wall is lost.

Current Behavior

During import of gbXML geometry a wall is lost.

Expected Behavior

Surfaces should not be removed.

Steps to Reproduce

The issue exists both in OpenStudio CLI 2.8.1 (comes with Revit) and OpenStudioApplication 3.5 and 2.8.1, so, I believe it is a general API issue. The gbXML is in the attachment.

Possible Solution

It's been a very long and unsuccessful story, but I do believe it is possible to import gbXML geometry to osm or idf without losses.

Details

Environment

Windows 10, Revit 2023 to create geometry, OpenStudio CLI 2.8.1, OpenStudioApp 3.5 or 2.8.1

Context

Without correct import of gbXML it is hardly possible to use OpenStudio in real projects. Project1.zip

jmarrec commented 1 year ago

@nickger thanks for the report. More information would be welcome so we don't have to spend a lot of time trying to reproduce.

jmarrec commented 1 year ago

Can't see any wall missing... Marking as Can't Reproduce for now but leaving open so you can give more information as appropriate. If not I'll close it.

rt = OpenStudio::GbXML::GbXMLReverseTranslator.new
m = rt.loadModel('Project1.xml').get
model_sfs = m.getSurfaces.map(&:nameString) + m.getShadingSurfaces.map(&:nameString)

require 'nokogiri'
doc = File.open("Project1.xml") { |f| Nokogiri::XML(f) }
sfs = {}
doc.xpath('//xmlns:Surface').each do |s|
  sfs[s.attributes['id'].value] = s.attributes['surfaceType'].value
end
[1] temp(main)> sfs.size
=> 16
[2] temp(main)> model_sfs.size
=> 17
[3] temp(main)> sfs.keys - model_sfs
=> []
[4] temp(main)> model_sfs - sfs.keys
=> ["aim0223 Reversed"]
jmarrec commented 1 year ago

Side note: the gbxml validation shows these

[openstudio.XMLValidator] <1> xsdValidate.parseFileError: XML error 17.1868: Element '{http://www.gbxml.org/schema}Transmittance': The attribute 'surfaceType' is required but missing.
    at Project1.xml:1387 while processing "surfaceType"
[openstudio.XMLValidator] <1> xsdValidate.parseFileError: XML error 17.1866: Element '{http://www.gbxml.org/schema}WeekSchedule', attribute 'type': The attribute 'type' is not allowed.
    at Project1.xml:1487 while processing "type"
[openstudio.XMLValidator] <1> xsdValidate.parseFileError: XML error 17.1868: Element '{http://www.gbxml.org/schema}WeekSchedule': The attribute 'scheduleType' is required but missing.
    at Project1.xml:1487 while processing "scheduleType"
[openstudio.XMLValidator] <1> xsdValidate.parseFileError: XML error 17.1866: Element '{http://www.gbxml.org/schema}WeekSchedule', attribute 'type': The attribute 'type' is not allowed.
    at Project1.xml:1491 while processing "type"
[openstudio.XMLValidator] <1> xsdValidate.parseFileError: XML error 17.1868: Element '{http://www.gbxml.org/schema}WeekSchedule': The attribute 'scheduleType' is required but missing.
    at Project1.xml:1491 while processing "scheduleType"
[openstudio.XMLValidator] <1> xsdValidate.parseFileError: XML error 17.1866: Element '{http://www.gbxml.org/schema}DaySchedule', attribute 'type': The attribute 'type' is not allowed.
    at Project1.xml:1495 while processing "type"
[openstudio.XMLValidator] <1> xsdValidate.parseFileError: XML error 17.1868: Element '{http://www.gbxml.org/schema}DaySchedule': The attribute 'scheduleType' is required but missing.
    at Project1.xml:1495 while processing "scheduleType"
[openstudio.XMLValidator] <1> xsdValidate.parseFileError: XML error 17.1866: Element '{http://www.gbxml.org/schema}DaySchedule', attribute 'type': The attribute 'type' is not allowed.
    at Project1.xml:1522 while processing "type"
[openstudio.XMLValidator] <1> xsdValidate.parseFileError: XML error 17.1868: Element '{http://www.gbxml.org/schema}DaySchedule': The attribute 'scheduleType' is required but missing.
    at Project1.xml:1522 while processing "scheduleType"
[openstudio.XMLValidator] <1> xsdValidate.parseFileError: XML error 17.1871: Element '{http://www.gbxml.org/schema}DesignHeatRH': This element is not expected.
    at Project1.xml:1552
[openstudio.XMLValidator] <1> xsdValidate.parseFileError: XML error 17.1871: Element '{http://www.gbxml.org/schema}DesignHeatRH': This element is not expected.
    at Project1.xml:1560
nickger commented 1 year ago

Here are the pictures: gbXML OSM Is it a viewer issue? How can I check surfaces in osm model? Any import report?

How can I run this validator and get a report? I will send it to Autodesk...

jmarrec commented 1 year ago

@nickger What is the name of the missing Red surface in Revit? And did you check whether it's in the gbXML Project1.xml to begin with.

The Validator happens when you load the gbxml

rt = OpenStudio::GbXML::GbXMLReverseTranslator.new
m = rt.loadModel('Project1.xml').get
nickger commented 1 year ago

I don't understand your code, what language is this..? Is it in interactive mode or smthg? The surface "aim0433"

jmarrec commented 1 year ago

This is ruby.

I'm using irb/pry interactive interpreter (REPL) in this specific case. Set "Optional - setup ruby" in https://nrel.github.io/OpenStudio-user-documentation/getting_started/getting_started/

But you can throw that code in "test.rb" (next to Project1.xml) and use openstudio.exe test.rb without even installing ruby.

$ ls
Project1.xml
test.rb
$ cat test.rb
rt = OpenStudio::GbXML::GbXMLReverseTranslator.new
m = rt.loadModel('Project1.xml').get
$ openstudio test.rb
[openstudio.XMLValidator] <1> xsdValidate.parseFileError: XML error 17.1868: Element '{http://www.gbxml.org/schema}Transmittance': The attribute 'surfaceType' is required but missing.
    at /Users/julien/Downloads/temp/Project1.xml:1387 while processing "surfaceType"
[openstudio.XMLValidator] <1> xsdValidate.parseFileError: XML error 17.1866: Element '{http://www.gbxml.org/schema}WeekSchedule', attribute 'type': The attribute 'type' is not allowed.
    at /Users/julien/Downloads/temp/Project1.xml:1487 while processing "type"
[openstudio.XMLValidator] <1> xsdValidate.parseFileError: XML error 17.1868: Element '{http://www.gbxml.org/schema}WeekSchedule': The attribute 'scheduleType' is required but missing.
    at /Users/julien/Downloads/temp/Project1.xml:1487 while processing "scheduleType"
[openstudio.XMLValidator] <1> xsdValidate.parseFileError: XML error 17.1866: Element '{http://www.gbxml.org/schema}WeekSchedule', attribute 'type': The attribute 'type' is not allowed.
    at /Users/julien/Downloads/temp/Project1.xml:1491 while processing "type"
[openstudio.XMLValidator] <1> xsdValidate.parseFileError: XML error 17.1868: Element '{http://www.gbxml.org/schema}WeekSchedule': The attribute 'scheduleType' is required but missing.
    at /Users/julien/Downloads/temp/Project1.xml:1491 while processing "scheduleType"
[openstudio.XMLValidator] <1> xsdValidate.parseFileError: XML error 17.1866: Element '{http://www.gbxml.org/schema}DaySchedule', attribute 'type': The attribute 'type' is not allowed.
    at /Users/julien/Downloads/temp/Project1.xml:1495 while processing "type"
[openstudio.XMLValidator] <1> xsdValidate.parseFileError: XML error 17.1868: Element '{http://www.gbxml.org/schema}DaySchedule': The attribute 'scheduleType' is required but missing.
    at /Users/julien/Downloads/temp/Project1.xml:1495 while processing "scheduleType"
[openstudio.XMLValidator] <1> xsdValidate.parseFileError: XML error 17.1866: Element '{http://www.gbxml.org/schema}DaySchedule', attribute 'type': The attribute 'type' is not allowed.
    at /Users/julien/Downloads/temp/Project1.xml:1522 while processing "type"
[openstudio.XMLValidator] <1> xsdValidate.parseFileError: XML error 17.1868: Element '{http://www.gbxml.org/schema}DaySchedule': The attribute 'scheduleType' is required but missing.
    at /Users/julien/Downloads/temp/Project1.xml:1522 while processing "scheduleType"
[openstudio.XMLValidator] <1> xsdValidate.parseFileError: XML error 17.1871: Element '{http://www.gbxml.org/schema}DesignHeatRH': This element is not expected.
    at /Users/julien/Downloads/temp/Project1.xml:1552
[openstudio.XMLValidator] <1> xsdValidate.parseFileError: XML error 17.1871: Element '{http://www.gbxml.org/schema}DesignHeatRH': This element is not expected.
    at /Users/julien/Downloads/temp/Project1.xml:1560
jmarrec commented 1 year ago

aim0433 is NOT inside your Project1.xml. Seems like the problem is between Revit > GbXML.

I'm closing this issue, but if you have more questions the comments are still open.

nickger commented 1 year ago

Now I remember why I gave up with OpenStudio... Yes it IS inside of Project1.xml! Project1.zip

jmarrec commented 1 year ago

@nickger I think I'm being more than helpful here, and I'm definitely trying to go the extra mile to provide detailed, helpful answers, so I'd very much prefer if you avoided using a derogatory tone.

Your Original Post has this link: https://github.com/NREL/OpenStudio/files/10870203/Project1.zip and no, it is not in there. Your new link does not include the same Project1.xml.

jmarrec commented 1 year ago

Using the same code as in https://github.com/NREL/OpenStudio/issues/4809#issuecomment-1457698303 with your new XML.

[1] temp(main)> sfs.size
=> 17
[2] temp(main)> model_sfs.size
=> 18
[3] temp(main)> sfs.keys - model_sfs
=> []
[4] temp(main)> model_sfs - sfs.keys
=> ["aim0251 Reversed"]

Your surface is there

puts m.getSurfaceByName('aim0433').get
OS:Surface,
  {f5bd285d-e4f1-4fd0-a538-0d11bb8019bd}, !- Handle
  aim0433,                                !- Name
  Wall,                                   !- Surface Type
  {6418a26c-76a1-41f0-8420-496f4ae07153}, !- Construction Name
  {445626f5-ecb4-4d6b-9043-047b9e1e9c26}, !- Space Name
  Outdoors,                               !- Outside Boundary Condition
  ,                                       !- Outside Boundary Condition Object
  SunExposed,                             !- Sun Exposure
  WindExposed,                            !- Wind Exposure
  ,                                       !- View Factor to Ground
  ,                                       !- Number of Vertices
  2.1702194, 0, 0,                        !- X,Y,Z Vertex 1 {m}
  3.6796699, 0.752727, 0,                 !- X,Y,Z Vertex 2 {m}
  4.5094599, 1.1755261, 3.15,             !- X,Y,Z Vertex 3 {m}
  2.1702194, 0, 3.15;                     !- X,Y,Z Vertex 4 {m}
nickger commented 1 year ago

So, it's the viewer issue?

jmarrec commented 1 year ago

Your surface is not planar, so the viewer can't display it. Running OSApp with debug messages enabled in console mode:

OPENSTUDIO_APPLICATION_DEBUG=1 /Applications/OpenStudioApplication-1.5.0/OpenStudioApp.app/Contents/MacOS/OpenStudioApp

Then loading the resulting OSM and going to the geometry tab, I see:

[utilities.geometry.computeTriangulation] <1> All points must be on z = 0 plane for triangulation methods
[modelToThreeJS] <1> Failed to triangulate surface aim0433 with 0 sub surfaces
nickger commented 1 year ago

Ok, that's better. What tolerance is acceptable for OS and in what metrics? So I can preprocess gbXML to check planarity.

jmarrec commented 1 year ago

See here.

https://github.com/NREL/OpenStudio/blob/2c467849b317ee6e3a67752ecd814e6a9806874a/src/utilities/geometry/Geometry.hpp#L110-L113

Implementation at https://github.com/NREL/OpenStudio/blob/develop/src/utilities/geometry/Geometry.cpp#L460