-
Notifications
You must be signed in to change notification settings - Fork 197
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
insertComponent can create duplicate unique model objects #2610
Comments
Expected behavior would be to only keep the unique objects from the Component being inserted? (insertComponent relies on on addObjects, so perhaps could be addressed in conjunction with #3351) |
Or somehow merge the new unique object content with existing one, easiest and probably most clear way would be to replace existing unique object with the new one |
Make a dummy component with a unique model object (site mains water temperature, building, facility) |
@jmarrec I was able to do that, and reproduce the issue. So should the logic be: right before this line, remove any unique model objects from the workspace that match types found in If I use |
OpenStudio/src/model/Model.hpp Lines 260 to 278 in 93f1c74
There's also a bunch of cases with cache eg: OpenStudio/src/model/Model.hpp Lines 115 to 117 in 93f1c74
Your insertion point is a potential candidate. as I noted above, in addObjects we could perhaps do something too. |
@jmarrec Does this issue pre-date any of the "model merge" methods? Would the best option here be to update |
Are you referring to ModelMerger ? OpenStudio/src/model/ModelMerger.cpp Lines 90 to 110 in dab8620
This is specifically for merging stuff from floorspace json into your model, and it does things that go beyond unique model objects, it tries to merge spaces and co. |
I couldn't tell from reading through this, is the goal to replace existing unique objects or to merge with them? If that question is still being debated I would like to advocate for doing a clean replace. There always seems to be corner cases, so if folks have some of those in mind I think it would be helpful to identify them. @joseph-robertson I think the link to code in your comment #2610 (comment) is out of date. The link takes me to Model_Impl::disconnect which I don't think is what you were referring to. Can you update that link? |
@kbenne I was originally talking about right before this line: Check out the linked PR to see the start of my implementation (specifically The problem I ran into (and thus sort of halted working on this) was that, for example, if you remove |
Ah yes. I recall some discussion about this. I think you could drop down to some workspace level methods to remove the unique objects, therefore avoiding the virtual ModelObject::remove which is causing the unwanted extra removes. Workspace::removeObject(handle) would probably be what you want. This is taking advantage of the behavior that is causing us pain on #4241. I guess as you may know the wrinkle is fixing up the handles for any objects that reference the (removed) unique object. You either have to ensure that the new object has the same handle or you have to go through and update handle references. I think either can be accomplished with workspace level operations. ie setField. |
A crude merge would be something like move every characteristic of the unique modelobject to the target one (except the handle).
|
Addresses #2610, insertComponent can create duplicate unique model objects
m = OpenStudio::Model::Model.new
m.getSite
m.getSiteWaterMainsTemperature
m.getWeatherFile
remote = OpenStudio::RemoteBCL.new
remote.downloadComponent('f38beff0-edc6-0131-6605-48e0eb16a403')
component = remote.waitForComponentDownload()
component = component.get
osc_path = component.files("osc")[0]
vt = OpenStudio::OSVersion::VersionTranslator.new
component_object = vt.loadComponent(OpenStudio::Path.new(osc_path))
componentData = m.insertComponent(component_object.get)
puts m
The text was updated successfully, but these errors were encountered: