Esempio n. 1
0
        private static TSD.TSDDocument GetTSDDocument(bool Save)
        {
            TSD.TSDDocument aTSDDocument = null;
            try
            {
                object aObject = System.Runtime.InteropServices.Marshal.GetActiveObject("TSD.Document");
                if (aObject != null && aObject is TSD.TSDDocument)
                {
                    aTSDDocument = aObject as TSD.TSDDocument;
                    if (Save)
                    {
                        aTSDDocument.save();
                    }
                    aTSDDocument.close();
                }
            }
            catch
            {
            }

            if (aTSDDocument == null)
            {
                aTSDDocument = new TSD.TSDDocument();
            }

            return(aTSDDocument);
        }
Esempio n. 2
0
 /// <summary>
 /// Close TAS TSD Document. READ ME ==============
 /// Option 1 = File will be close when Dynamo is restarted
 /// if you use Dynamo with Revit you need to restart both
 /// Option 2 = when script is done and you confirmed it was saved just
 /// go to TaskManager and End Process for TSD.exe
 /// </summary>
 /// <param name="TSDDocument">TSD Document</param>
 /// <returns name="Boolean">Boolean</returns>
 /// <search>
 /// TAS, TSDDocument, tas, TSDDdocument, close tsddocument, closetsddocument
 /// </search>
 public static bool Close(TSDDocument TSDDocument)
 {
     TSDDocument.pTSDDocument.close();
     TSDDocument.pTSDDocument = null;
     TSDDocument = null;
     return(true);
 }
Esempio n. 3
0
        public static WeatherData ToSAM_WeatherData(this TSD.TSDDocument tSDDocument, int year = 2018)
        {
            if (tSDDocument == null)
            {
                return(null);
            }

            return(ToSAM_WeatherData(tSDDocument.SimulationData, year));
        }
Esempio n. 4
0
        void IDisposable.Dispose()
        {
            if (pTSDDocument != null)
            {
                if (pSave)
                {
                    pTSDDocument.save();
                }

                pTSDDocument.close();
                pTSDDocument = null;
            }
        }
Esempio n. 5
0
 //Close and save the TSD Document
 private void CloseTsdDocument(bool save = true)
 {
     if (tsdDocument != null)
     {
         if (save == true)
         {
             tsdDocument.save();
         }
         tsdDocument.close();
         if (tsdDocument != null)
         {
             ClearCOMObject(tsdDocument);
             tsdDocument = null;
         }
     }
 }
Esempio n. 6
0
        //TODO: Do we need both of these?
        //To get the TSD Document
        private TSD.TSDDocument GetTsdDocumentReadOnly()
        {
            tsdDocument = new TSD.TSDDocument();
            if (!String.IsNullOrEmpty(tsdFilePath) && System.IO.File.Exists(tsdFilePath))
            {
                tsdDocument.openReadOnly(tsdFilePath);
            }

            else if (!String.IsNullOrEmpty(tsdFilePath))
            {
                tsdDocument.create(tsdFilePath); //What if an existing file has the same name?
            }
            else
            {
                BH.Engine.Base.Compute.RecordError("The TSD file does not exist");
            }
            return(tsdDocument);
        }
Esempio n. 7
0
        protected virtual void Dispose(bool disposing)
        {
            if (!disposed)
            {
                if (disposing)
                {
                    // TODO: dispose managed state (managed objects).
                    if (tSDDocument != null)
                    {
                        tSDDocument.close();
                        Core.Modify.ReleaseCOMObject(tSDDocument);
                        tSDDocument = null;
                    }
                }

                // TODO: free unmanaged resources (unmanaged objects) and override a finalizer below.
                // TODO: set large fields to null.

                disposed = true;
            }
        }
Esempio n. 8
0
        public static TSD.TSDDocument TSDDocument()
        {
            TSD.TSDDocument tSDDocument = null;

            try
            {
                object aObject = Marshal.GetActiveObject("Document");

                if (aObject != null)
                {
                    tSDDocument = aObject as TSD.TSDDocument;
                    Core.Modify.ReleaseCOMObject(aObject);
                    tSDDocument = null;
                }
            }
            catch (Exception exception)
            {
                string message = exception.Message;
            }

            tSDDocument = new TSD.TSDDocument();

            return(tSDDocument);
        }
 protected override void Create()
 {
     Document = new TSD.TSDDocument();
 }
Esempio n. 10
0
 private TSDDocument(TSD.TSDDocument TSDDocument, bool Save)
 {
     pSave        = Save;
     pTSDDocument = TSDDocument;
 }
Esempio n. 11
0
 internal TSDDocument(string FilePath, bool Save)
 {
     pSave        = Save;
     pTSDDocument = GetTSDDocument(Save);
     pTSDDocument.open(FilePath);
 }
Esempio n. 12
0
 /// <summary>
 /// Opens TAS TBD Document
 /// </summary>
 /// <param name="Path">Building Name</param>
 /// <returns name="TBDDocument">TBD Document</returns>
 /// <search>
 /// TAS, TBDDocument, tas, tbddocument, new tbddocument, newtbddocument
 /// </search>
 public static TSDDocument New(string Path)
 {
     TSD.TSDDocument aTSDDocument = GetTSDDocument(false);
     aTSDDocument.SimulationData.buildingPath = Path;
     return(new TSDDocument(aTSDDocument, false));
 }