Repository.Model.GetModel: Difference between revisions

From ReliaWiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(11 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Template:APIBreadcrumb|10|Repository}}
{{Template:API}}{{Template:APIBreadcrumb|.[[Repository Class|Repository]]}}
{{Template:API}}
Gets the model with the designated ID number and returns it as a '''[[CModel Class|cModel]]''' object. Returns nothing if the model does not exist or is not in the current project.


To get a local model, you must first specify a current/active project (see the [[Repository.Project.SetCurrentProject|Project.SetCurrentProject method]]). There is no need to specify a current project for global models.  
 
<onlyinclude>Returns a '''[[CModel Class|cModel]]''' object that represents a given model resource in the current project. Returns nothing if the model does not exist or is not in the current project.</onlyinclude>


== Syntax ==
== Syntax ==
''object''.'''Model.GetModel(''Integer'')'''
'''.Model.GetModel'''(''ID'')
 
where ''object'' is a variable that represents a Repository object.


=== Parameters ===
=== Parameters ===
{| {{APITable}}
''ID''
|-
:Required. Integer. The ID number of the model to retrieve.
|ID{{APIParam|Required}}||'''Integer'''. The ID number of the model to retrieve.
|}




== Example ==
== Example ==
These examples assume that a model with the ID# 47 exists in the repository.
This example assumes that a model with ID #47 exists in the first project of a Synthesis repository.


  '''VBA'''<br>
  '''VBA'''
  {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
{{APIComment|...'Add code to connect to a Synthesis repository.}}
{{APIComment|'Declare a new Repository object and connect to a Synthesis repository.}}
  {{APIComment|...'If getting a local model, add code to specify the current project.}}<br>
  {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
  {{APIPrefix|Dim}} AModel {{APIPrefix|As}} cModel
  MyRepository.ConnectToAccessRepository({{APIString|"C:\RSRepository1.rsr10"}})
  {{APIPrefix|Set}} AModel = MyRepository.Model.GetModel(47)
   
  {{APIComment|'Get model #47 from project#1.}}
  {{APIPrefix|Dim}} AModel {{APIPrefix|As}} cModel
  MyRepository.Project.SetCurrentProject(1)
  {{APIPrefix|Set}} AModel = MyRepository.Model.GetModel(47)
{{APIComment|'Output sample: Display the name and ID of the model.}}
  {{APIPrefix|Dim}} ModelName {{APIPrefix|As}} String
  {{APIPrefix|Dim}} ModelID {{APIPrefix|As}} Integer
  ModelName = AModel.Name
  ModelID = AModel.ID
  MsgBox ({{APIString|"You got "}} & ModelName & {{APIString|", ID#"}} & ModelID)


  '''VB.NET'''<br>
  '''VB.NET'''
  {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
{{APIComment|...'Add code to connect to a Synthesis repository.}}
{{APIComment|'Declare a new Repository object and connect to a Synthesis repository.}}
  {{APIComment|...'If getting a local model, add code to specify the current project.}}<br>
  {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
  {{APIPrefix|Dim}} AModel {{APIPrefix|As}} cModel
  MyRepository.ConnectToAccessRepository({{APIString|"C:\RSRepository1.rsr10"}})
  AModel = MyRepository.Model.GetModel(47)
 
  {{APIComment|'Get model #47 from project#1.}}
  {{APIPrefix|Dim}} AModel {{APIPrefix|As}} cModel
  MyRepository.Project.SetCurrentProject(1)
  AModel = MyRepository.Model.GetModel(47)
{{APIComment|'Output sample: Display the name and ID of the model.}}
  {{APIPrefix|Dim}} ModelName {{APIPrefix|As}} String
  {{APIPrefix|Dim}} ModelID {{APIPrefix|As}} Integer
  ModelName = AModel.Name
  ModelID = AModel.ID
  MsgBox ({{APIString|"You got "}} & ModelName & {{APIString|", ID#"}} & ModelID)

Latest revision as of 18:53, 9 June 2016

APIWiki.png


Member of: SynthesisAPI.Repository


Returns a cModel object that represents a given model resource in the current project. Returns nothing if the model does not exist or is not in the current project.

Syntax

.Model.GetModel(ID)

Parameters

ID

Required. Integer. The ID number of the model to retrieve.


Example

This example assumes that a model with ID #47 exists in the first project of a Synthesis repository.

VBA

 'Declare a new Repository object and connect to a Synthesis repository. 
  Dim MyRepository As New Repository
  MyRepository.ConnectToAccessRepository("C:\RSRepository1.rsr10")
   
 'Get model #47 from project#1. 
  Dim AModel As cModel
  MyRepository.Project.SetCurrentProject(1)
  Set AModel = MyRepository.Model.GetModel(47)

 'Output sample: Display the name and ID of the model. 
  Dim ModelName As String
  Dim ModelID As Integer
  ModelName = AModel.Name
  ModelID = AModel.ID
  MsgBox ("You got " & ModelName & ", ID#" & ModelID)
VB.NET

 'Declare a new Repository object and connect to a Synthesis repository. 
  Dim MyRepository As New Repository
  MyRepository.ConnectToAccessRepository("C:\RSRepository1.rsr10")
 
 'Get model #47 from project#1. 
  Dim AModel As cModel
  MyRepository.Project.SetCurrentProject(1)
  AModel = MyRepository.Model.GetModel(47)

 'Output sample: Display the name and ID of the model. 
  Dim ModelName As String
  Dim ModelID As Integer
  ModelName = AModel.Name
  ModelID = AModel.ID
  MsgBox ("You got " & ModelName & ", ID#" & ModelID)