public SAMTBDDocument(string path, bool readOnly = false) { this.readOnly = readOnly; if (string.IsNullOrWhiteSpace(path)) { return; } if (File.Exists(path)) { FileInfo fileInfo = new FileInfo(path); if (Core.Query.Locked(fileInfo)) { readOnly = true; } } if (File.Exists(path)) { if (readOnly) { TBDDocument.openReadOnly(path); } else { TBDDocument.open(path); } } else { TBDDocument.create(path); } }
public static bool TBDSizing(string tbdFile, bool run = false) { if (!run) { return(false); } if (string.IsNullOrEmpty(tbdFile)) { BH.Engine.Base.Compute.RecordError("Please provide a valid TBD file path"); return(false); } TBDDocument tbdDocument = new TBDDocument(); tbdDocument.open(tbdFile); if (tbdDocument != null) { tbdDocument.sizing(0); } tbdDocument.save(); tbdDocument.close(); int intrefcountTBD = 0; do { intrefcountTBD = Marshal.FinalReleaseComObject(tbdDocument); } while (intrefcountTBD > 0); tbdDocument = null; return(true); }
public static bool TBDSizing(string tbdFile, int startDay = 0, int endDay = 365, bool autoViewResults = false, bool run = false) { if (!run) { return(false); } if (!run) { return(false); } if (string.IsNullOrEmpty(tbdFile)) { BH.Engine.Base.Compute.RecordError("Please provide a valid TBD file path"); return(false); } TBDDocument tbdDocument = new TBDDocument(); tbdDocument.open(tbdFile); string tsdFile = tbdFile.Replace(".tbd", ".tsd"); if (tbdDocument != null) { tbdDocument.simulate(startDay, endDay, autoViewResults ? 1 : 0, 1, 0, 0, tsdFile, 0, 0); tbdDocument.save(); tbdDocument.close(); } int intrefcountTBD = 0; do { intrefcountTBD = Marshal.FinalReleaseComObject(tbdDocument); } while (intrefcountTBD > 0); tbdDocument = null; return(true); }