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

OpenStudio 3.4.0 Python subsurface intersect/match

asked 2023-02-03 08:54:07 -0600

mattkoch's avatar

updated 2023-02-06 07:52:51 -0600

I am working on a geometry modeler for OpenStudio. I am doing this in FreeCAD 0.20.1 because of its parametric nature, its Python backbone and its open availability (as opposed to SketchUp these days), and I am pairing it with the Python version of the OpenStudio 3.4.0 library (Thank You for porting it to Python!).

At this point, I can generate buildings with or without EXTERIOR windows/doors, and they show up and seem to run OK in OpenStudioApp 1.4.0 (with OpenStudio 3.4.0). I can also change the "3.4.0" to "2.9.1" in the .osm file, then add an extra line to all SubSurface entries (seems like Shading Control was dropped for later versions of OS?), and then open it in the old OpenStudio 2.9.1 SketchUp plugin, and it seems to then show up OK there as well.

To achieve surface intersecting and matching, I am using the following functions from the Python version of the OpenStudio 3.4.0 library:

import openstudio

...

openstudio.model.intersectSurfaces(spaces)
openstudio.model.matchSurfaces(spaces)

where spaces is an OpenStudio space vector like so:

spaces = openstudio.model.SpaceVector()

Like I said, so far, so good. However, this fails when I add INTERIOR windows or doors. Then the intersecting and matching no longer work. But, I can still modify the .osm file as indicated and open it up in the OpenStudio 2.9.1 SketchUp plugin. There I can then first do an intersect and then a match, and then it magically seems to work!

So, I was just wondering if this might ring a bell with anyone, maybe along the lines of intersect/match working OK in 2.9.1 Ruby but not OK in 3.4.0 Python or some such? Are there alternative OpenStudio Python functions?

As a bonus question, I was hoping to change the version from 3.4.0 to 2.9.1 via an OpenStudio Python function, so I don't have to edit the .osm file I create from FreeCAD manually and after the fact? I can't seem to find anything about that.

EDIT after logging <<<

I placed the following near the beginning of "it all":

logger = openstudio.FileLogSink("E:/OpenStudio/Measures/Python/test.log")
logger.setLogLevel(openstudio.Debug)

That seems to result in information being recorded to test.log. The outputs are as follows - it is long, so excerpts here only.

Each of the three versions has a bunch of the following:

[openstudio.model.PlanarSurface] <-2> Before setVertices have 11 fields.
[openstudio.model.PlanarSurface] <-2> After clearExtensibleGroups in setVertices have 11 fields.
[openstudio.model.PlanarSurface] <-2> After setVertices have 23 fields.  Size of vertices is 4.

Version 1 (no windows)

... interspersed with a bunch of the above are these three parts:

[openstudio.model.Surface] <-1> Intersection of 'Surface 3' with 'Surface 7' results in (Surface 3), (Surface 7),,[Surface 19], []

[openstudio.model.Surface] <-1> Intersection of 'Surface ...
(more)
edit retag flag offensive close merge delete

Comments

"Then the intersecting and matching no longer work". What doesn't work? Does it crash? Can you provide a dumb .OSM and some sample python code so we can reproduce?

Instead of using FileLogSink, if you can see the console output, do this:

openstudio.Logger.instance().standardOutLogger().setLogLevel(openstudio.Debug)

LogLevels: Trace, Debug, Info, Warn (default), Error, Fatal

Julien Marrec's avatar Julien Marrec  ( 2023-02-06 05:12:05 -0600 )edit

I strongly caution against assuming that a model created in a given OS version will work in an earlier one, so use this footgun at your own risk: model.versionObject().get().setString(1, "2.9.0")

Julien Marrec's avatar Julien Marrec  ( 2023-02-06 05:14:20 -0600 )edit

Thank you Julian Marrec. Last thing first, I agree 100% with your caution, and I am only using the 2.9.1 hack so I can keep using SketchUp 2017 for geometry debugging purposes. Should I ever get to the point where this works, this should no longer be needed.

Now, as to "no longer work". I have a simple model with three connected spaces of different heights. In the 1st version, there are no window, in the 2nd version there is one exterior window only in one of the spaces and in the 3rd version there is one interior window only between that space and the adjacent space. ... more next comment.

mattkoch's avatar mattkoch  ( 2023-02-06 07:25:51 -0600 )edit

all three versions are treated identically in my FreeCAD to OpenStudio conversion, and all run to "completion" without error. However, only the 1st and 2nd show the proper intersecting and matching. The 3rd shows intersecting and matching on walls where there is not the interior window, but NONE of either on the wall with the interior window. Wish I could share the .OSM files, but don't know how. Have not had time yet to implement macumber's logging to get more info.

mattkoch's avatar mattkoch  ( 2023-02-06 07:30:23 -0600 )edit

Just to close the loop, I did this with Trace, Info, Debug, Warn, Error and Fatal now - some result in no messages at all, for others, all that is added to what I already mentioned above is a bunch of the following:

[utilities.idf.Workspace] <-3> Adding object with handle {0d2e5a46-2c6b-4c09-b3cf-d7dc934f9aab}

Not sure where this leaves things now. My hope was that there might have been a difference between 3.4.0 computeIntersection and 2.9.X-LTS computeIntersection, but that does not seem to be the case now. Both seem to disallow subsurface intersections? How does SketchUp 2.9.1 do it?

mattkoch's avatar mattkoch  ( 2023-02-06 19:25:03 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2023-02-10 22:14:10 -0600

mattkoch's avatar

updated 2023-02-10 22:15:04 -0600

This is getting to be pretty long so I want to close this off by stating that macumber had suggested intersection does not have to happen within openstudio. In fact, according to him, intersecting within the 2.9.1 SketchUp plugin happens with SketchUp methods. So he suggested that FreeCAD might have its own intersecting methods. That is indeed so, and it may well be that this is the real answer here. It might also address the odd diagonals I tend to receive in SketchUp when my surfaces include "insular" patches. At any rate, I believe his suggestion got me unstuck, so thank you for that, macumber!

edit flag offensive delete link more
1

answered 2023-02-05 18:01:19 -0600

First of all, that sounds like a really cool project Matt! I hope you may decide to make this available, I know many people would be interested in a SketchUp alternative.

I would suggest setting up an OpenStudio FileSinkLogger (Ruby example) so you can see any log messages that might come out when you run your code.

You are using the right methods in my opinion; you've probably already found these but here are links to the implementation of these methods in OpenStudio:

Are you drawing interior windows in both spaces in FreeCAD or just one? I don't think that an intersection will create a new SubSurface in one space to match an existing SubSurface in the other space.

If you continue having problems, I suggest saving your model pre-intersect/matching then attach it to an issue on https://github.com/NREL/OpenStudio/is... and tag https://github.com/ggartside who has been working on fixing some geometry issues.

edit flag offensive delete link more

Comments

Thank you macumber. it seems that intersectSurfaces calls computeIntersection, and that has the following parts:

if (!this->subSurfaces().empty() || !otherSurface.subSurfaces().empty()) {
    LOG(Error, "Subsurfaces are not allowed in intersection");
    return boost::none;
}

if (this->adjacentSurface() || otherSurface.adjacentSurface()) {
    LOG(Error, "Adjacent surfaces are not allowed in intersection");
    return boost::none;
}

... looks ominous. Also, is there documentation for FileSinkLogger?

mattkoch's avatar mattkoch  ( 2023-02-05 19:25:43 -0600 )edit
1

Also, one other reason I am hoping to make progress with FreeCAD is to reduce some of the labor, such as having to generate subsurfaces in the original surface and the adjacent surface. Instead, I am looking to make this happen automatically. Long way off, though.

mattkoch's avatar mattkoch  ( 2023-02-05 19:30:13 -0600 )edit

Yeah, those are the types of log messages I thought might be useful. Here is a link to the FileLogSink class. Here is the SDK documentation.

I have never seen this before, if you google "OpenStudio FileLogSink" there is a page that can find uses of the class

macumber's avatar macumber  ( 2023-02-05 19:30:56 -0600 )edit

Interesting, thanks to your link I was able to convert the Ruby into a Python and get some info out of it, sort of. Now, how to apply it to my code is another story. I suppose I have to mine the use cases for that. At least there are such.

mattkoch's avatar mattkoch  ( 2023-02-05 20:26:48 -0600 )edit

I was also looking for 2.9.X-LTS, following your links above. computeIntersection in Surface.cpp and intersectSurfaces in Space.cpp seem to have the same disallowance!

if (!this->subSurfaces().empty() || !otherSurface.subSurfaces().empty()){
  LOG(Error, "Subsurfaces are not allowed in intersection");
  return boost::none;
}
mattkoch's avatar mattkoch  ( 2023-02-06 08:03:35 -0600 )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: 2023-02-03 08:54:07 -0600

Seen: 249 times

Last updated: Feb 10 '23