/// <summary> /// Connects to a running instance of SmartPlant Review. /// </summary> /// <returns>Boolean indicating success or failure of the operation.</returns> public bool Connect() { DrApi = Activator.CreateInstance(SprImportedTypes.DrApi); if (DrApi == null) return false; try { // Set the startup fields _version = GetVersion(); _mdbPath = GetMdbPath(); _mdbDatabase = GetMdbDatabase(); _sessionName = GetSessionName(); //_nextTag = GetNextTag(); _nextAnnotation = GetNextAnnotation(); _processId = GetProcessId(); _designFiles = GetDesignFiles(); // Windows Windows = new SprApplicationWindows(this); // DbObjects _annotations = new SprAnnotationCollection(this); _tags = new SprTagCollection(this); // Create the default snapshot format DefaultSnapshot = new SprSnapShot { AntiAlias = 3, OutputFormat = SprSnapshotFormat.Jpg, AspectOn = true, Scale = 1 }; // Set the default snapshot directories SprSnapShot.TempDirectory = Environment.GetEnvironmentVariable("TEMP"); SprSnapShot.DefaultDirectory = Environment.SpecialFolder.MyPictures.ToString(); SprStatus = 0; } catch { return false; } return IsConnected; }
/// <summary> /// Attempts to open the specified session in the fileName. /// Any active session will first be closed. /// </summary> /// <param name="fileName">The full path of the session to load.</param> public void Open(string fileName) { if (!IsConnected) throw SprExceptions.SprNotConnected; // Try opening the file using the Api method call SprStatus = DrApi.SessionAttach(fileName); if (SprStatus != 0) throw SprException; // Set the session vars _mdbPath = GetMdbPath(); _mdbDatabase = GetMdbDatabase(); _sessionName = GetSessionName(); //_nextTag = GetNextTag(); _nextAnnotation = GetNextAnnotation(); _designFiles = GetDesignFiles(); _tags = new SprTagCollection(this); }