Repository.Model.GetAllModelsInfo: Difference between revisions

From ReliaWiki
Jump to navigation Jump to search
No edit summary
 
(25 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Template:APIClass|Repository Class|Repository}}
{{Template:API}}{{Template:DeprecatedAPI}}{{Template:APIBreadcrumb|.[[Repository Class|Repository]]}}
{{Template:Repository.GetAllModelsInfo.Cmt}}
 
 
<onlyinclude><includeonly>{{DeprecatedAPIpic}}</includeonly>Returns an array of '''[[NameIdPair_Class|NameIdPair]]''' objects that represent the name and ID pairs of the model resources in the current project. This includes internal models automatically created with any new repository (model ID#s 1 to 20).</onlyinclude>


== Syntax==
== Syntax==
*GetAllModelsInfo(){{APIPrefix|As}}[[NameIdPair Class|NameIdPair]]()
'''.Model.GetAllModelsInfo'''(''Filter'')


== Usage Example ==
===Parameters===
<div style="margin-right: 150px;">
''Filter''
In this usage example, the API is used to connect to a repository, retrieve one of the models in it and then calculate the reliability at a specified time, based on that model.
:Optional. A filter that returns a particular type of resource (e.g., global only, local and global only, etc.). Can be any [[ResourceFilterEnum Enumeration|ResourceFilterEnum]] constant. Default value = 0, which returns local resources only.  
{{APIComment|'Declare a new repository connection class.}}
  Dim MyRepository As New Repository
 
{{APIComment|'Connect to a Synthesis repository.}}
  Dim Success As Boolean = False
  Success = MyRepository.ConnectToRepository("C:\Users\Name\Documents\ReliaSoft\Files\repository.rsr9")
 
{{APIComment|'Get a list of the names/IDs of projects in the connected repository.}}
  Dim ListOfProjects() As NameIdPair
  ListOfProjects = MyRepository.GetAllProjects
 
{{APIComment|'Open the first project in the list.}}
  MyRepository.SetCurrentProject(ListOfProjects(0).ID)
 
{{APIComment|'Get a list of the names/IDs of models in the current project.}}
  Dim ListOfModels() As NameIdPair
  ListOfModels = MyRepository.GetAllModelsInfo()
 
{{APIComment|'Retrieve the first model in the list.}}
  Dim AModel as cModel
  AModel = MyRepository.GetModel(ListOfModels(0).ID)
 
{{APIComment|'Calculate the reliability at time &#61; 50 and save the result. See [[CModel.Reliability|Reliability]].}}
  Dim Rel as Double
  Rel = AModel.Reliability(50)
 
{{APIComment|'Disconnect from the repository.}}
  MyRepository.DisconnectFromRepository




</div>
== Example ==
This example assumes that models exist in the first available project of a repository.
'''VBA|VB.NET'''
{{APIComment|'Declare a new Repository object and connect to a Synthesis repository.}}
  {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
  MyRepository.ConnectToAccessRepository({{APIString|"C:\RSRepository1.rsr10"}})
 
{{APIComment|'Get a list of all local models in project #1.}}
  {{APIPrefix|Dim}} ListofModels() {{APIPrefix|As}} NameIDPair
  MyRepository.Project.SetCurrentProject (1) 
  ListofModels = MyRepository.Model.GetAllModelsInfo()
{{APIComment|'Output sample: Display the number of models in the project.}}
  {{APIPrefix|Dim}} NumberofElements {{APIPrefix|As}} Integer
  NumberofElements = UBound(ListofModels) - LBound(ListofModels) + 1
  MsgBox (NumberofElements)

Latest revision as of 18:53, 9 June 2016

APIWiki.png


This method has been deprecated and may be removed in future versions of the Synthesis API. Do not use it in new applications.


Member of: SynthesisAPI.Repository


Returns an array of NameIdPair objects that represent the name and ID pairs of the model resources in the current project. This includes internal models automatically created with any new repository (model ID#s 1 to 20).

Syntax

.Model.GetAllModelsInfo(Filter)

Parameters

Filter

Optional. A filter that returns a particular type of resource (e.g., global only, local and global only, etc.). Can be any ResourceFilterEnum constant. Default value = 0, which returns local resources only.


Example

This example assumes that models exist in the first available project of a repository.

VBA|VB.NET

 'Declare a new Repository object and connect to a Synthesis repository. 
  Dim MyRepository As New Repository
  MyRepository.ConnectToAccessRepository("C:\RSRepository1.rsr10")
  
 'Get a list of all local models in project #1. 
  Dim ListofModels() As NameIDPair
  MyRepository.Project.SetCurrentProject (1)  
  ListofModels = MyRepository.Model.GetAllModelsInfo()

 'Output sample: Display the number of models in the project. 
  Dim NumberofElements As Integer
  NumberofElements = UBound(ListofModels) - LBound(ListofModels) + 1
  MsgBox (NumberofElements)