Missing OS:Version IdfObject from Cloned OS Model

asked 2021-08-12 12:45:22 -0500

nigusse's avatar

updated 2021-10-01 03:48:26 -0500

Loaded OSM file using CSharp binding (V3.2.0), read each of the IdfObject and added them to IdfObjectVector (myNewObjVec). Then added the myNewObjVec into another instance of OpenStudio.Model(osNewModel) and saved the new model to a file. See the pseudo code below:

osNewModel.addObjects(myNewObjVec,true);
OpenStudio.Path p = OpenStudio.OpenStudioUtilitiesCore.toPath(newfname);
osNewModel.save(p, true);

The new OSM file was created correctly but the OS:Version IdfObject is missing from the new OSM file. As an alternative I created OS:Version IdfObject on the fly and tried to add it but did not work.

What am I missing?

edit retag flag offensive close merge delete

Comments

How did you create osNewModel? How are you trying to find the OS:Version object? Did you open the OSM file in a text editor and look for it?

macumber's avatar macumber  ( 2021-08-12 19:55:00 -0500 )edit

The OS model was created as follows:

private IdfObjectVector myNewObjVec = new IdfObjectVector();
private Model osNewModel = new OpenStudio.Model();
            OpenStudio.VersionTranslator VerTran = new VersionTranslator();
            OpenStudio.OptionalModel VerTranModelOpt = VerTran.loadModel(OpenStudioUtilitiesCore.toPath(filename));
            mOSImportModel = VerTranModelOpt.get();

I clone each of Idfobjects from the OS model and add them into myNewObjVec. osNewModel.addObjects(myNewObjVec,true); The new OSM doesn't run because the OS:Version object is missing.

nigusse's avatar nigusse  ( 2021-09-03 14:59:58 -0500 )edit

I could not open the new OSM file created in OpenStudio because of missing Version object and I confirmed this by text compare. I was able to run the new model by adding OS:Version object manually.

nigusse's avatar nigusse  ( 2021-09-03 15:14:44 -0500 )edit

That is odd, I don't see similar behavior in the Ruby bindings. Creating a new model should create a version object, https://github.com/NREL/OpenStudio/bl.... Perhaps this is a bug in the C# bindings? You could file it as an issue on the OpenStudio SDK GitHub repo.

macumber's avatar macumber  ( 2021-09-05 22:12:21 -0500 )edit

Thanks. Posted new OpenStudio issue #4433

nigusse's avatar nigusse  ( 2021-09-07 07:51:51 -0500 )edit