Repository.Model.AddModel: 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:
<noinclude>{{Template:API}}{{Template:APIBreadcrumb|10|.[[Repository Class|Repository]]}}</noinclude>
{{Template:API}}{{Template:APIBreadcrumb|.[[Repository Class|Repository]]}}




Saves a new [[CModel Class|cModel]] object to the current project. Returns a '''Boolean''' value; when true, indicates a successful save.  
<onlyinclude>Adds a new model resource to the current project. Returns a '''Boolean''' value; when true, indicates a successful save.</onlyinclude>  
<noinclude>
 
If a cModel object with the same name already exists in the current project, the application will automatically increment the name. For example, if "Model1" already exists, the new model might be renamed to "Model2. Model3, etc.)
 
'''Remarks''': If a model with the same name already exists in the destination project, the name will be incremented automatically. For example, if "Model1" already exists, the new model might be renamed to "Model2," "Model3," etc.
 
== Syntax ==
== Syntax ==
  '''.Model.AddModel'''(''m'')
  '''.Model.AddModel'''(''m'')
Line 10: Line 12:
=== Parameters ===
=== Parameters ===
''m''
''m''
:The [[CModel Class|cModel]] object to be added. (Required)
:Required. The [[CModel Class|cModel]] object that represents the model resource to be added.




Line 17: Line 19:
  '''VBA'''
  '''VBA'''
   
   
  {{APIComment|'Add code to connect to a Synthesis repository.}}
  {{APIComment|'Declare a new Repository object and connect to a Synthesis repository.}}
   {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
   {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
  {{APIComment|...}}
  MyRepository.ConnectToAccessRepository({{APIString|"C:\RSRepository1.rsr10"}})
 
  {{APIComment|'Create a new model. The following example creates a 2-parameter Weibull reliability model,}}
  {{APIComment|'Create a new model. The following example creates a 2-parameter Weibull reliability model,}}
  {{APIComment|'with beta 1 and eta 100. The model name is "MyNewModel."}}
  {{APIComment|'with beta &#61; 1 and eta &#61; 100. The model name is "MyNewModel."}}
  {{APIPrefix|Dim}} ModelType {{APIPrefix|As}} ModelTypeEnum
  {{APIPrefix|Dim}} ModelType {{APIPrefix|As}} ModelTypeEnum
  {{APIPrefix|Dim}} ModelCategory {{APIPrefix|As}} ModelCategoryEnum
  {{APIPrefix|Dim}} ModelCategory {{APIPrefix|As}} ModelCategoryEnum
  {{APIPrefix|Dim}} ModelName {{APIPrefix|As String}}
  {{APIPrefix|Dim}} ModelName {{APIPrefix|As String}}
  {{APIPrefix|Dim}} ModelParams(2) {{APIPrefix|As Double}}
  {{APIPrefix|Dim}} ModelParams(2) {{APIPrefix|As Double}}
    
    
  ModelType = ModelTypeEnum_Weibull2
  ModelType = ModelTypeEnum_Weibull2
  ModelCategory = ModelCategoryEnum_Reliability
  ModelCategory = ModelCategoryEnum_Reliability
  ModelName = {{APIString|"MyNewModel"}}
  ModelName = {{APIString|"MyNewModel"}}
  ModelParams(0) = 1
  ModelParams(0) = 1
  ModelParams(1) = 100
  ModelParams(1) = 100
   
   
  {{APIPrefix|Dim}} newModel {{APIPrefix|As New}} cModel
  {{APIPrefix|Dim}} newModel {{APIPrefix|As New}} cModel
  {{APIPrefix|Call}} newModel.SetModel(ModelType, ModelCategory, ModelName, ModelParams)
  {{APIPrefix|Call}} newModel.SetModel(ModelType, ModelCategory, ModelName, ModelParams)
   
   
  {{APIComment|'Add the new model to project #1. The model will be visible in the Synthesis repository upon refresh.}}
  {{APIComment|'Add the new model to project #1.}}
  MyRepository.Project.SetCurrentProject(1)   
  MyRepository.Project.SetCurrentProject(1)   
  {{APIPrefix|Call}} MyRepository.Model.AddModel(newModel)
  {{APIPrefix|Call}} MyRepository.Model.AddModel(newModel)


  '''VB.NET'''
  '''VB.NET'''
   
   
  {{APIComment|'Add code to connect to a Synthesis repository.}}
  {{APIComment|'Declare a new Repository object and connect to a Synthesis repository.}}
   {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
   {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
  {{APIComment|...}}
  MyRepository.ConnectToAccessRepository({{APIString|"C:\RSRepository1.rsr10"}})
 
  {{APIComment|'Create a new model. The following example creates a 2-parameter Weibull reliability model,}}
  {{APIComment|'Create a new model. The following example creates a 2-parameter Weibull reliability model,}}
  {{APIComment|'with beta 1 and eta 100. The model name is "MyNewModel."}}
  {{APIComment|'with beta &#61; 1 and eta &#61; 100. The model name is "MyNewModel."}}
  {{APIPrefix|Dim}} newModel {{APIPrefix|As New}} cModel(ModelTypeEnum.Weibull2, ModelCategoryEnum.Reliability, {{APIString|"MyNewModel"}}, 1, 100)
  {{APIPrefix|Dim}} newModel {{APIPrefix|As New}} cModel(ModelTypeEnum.Weibull2, ModelCategoryEnum.Reliability, {{APIString|"MyNewModel"}}, 1, 100)
   
   
  {{APIComment|'Add the new model to project #1. The model will be visible in the Synthesis repository upon refresh.}}
  {{APIComment|'Add the new model to project #1.}}
  MyRepository.Project.SetCurrentProject(1)   
  MyRepository.Project.SetCurrentProject(1)   
  MyRepository.Model.AddModel(newModel)
  MyRepository.Model.AddModel(newModel)
</noinclude>

Latest revision as of 20:35, 18 August 2016

APIWiki.png


Member of: SynthesisAPI.Repository


Adds a new model resource to the current project. Returns a Boolean value; when true, indicates a successful save.


Remarks: If a model with the same name already exists in the destination project, the name will be incremented automatically. For example, if "Model1" already exists, the new model might be renamed to "Model2," "Model3," etc.

Syntax

.Model.AddModel(m)

Parameters

m

Required. The cModel object that represents the model resource to be added.


Example

This example creates a new model resource, and then saves it in the first available project in 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")
 
 'Create a new model. The following example creates a 2-parameter Weibull reliability model, 
 'with beta = 1 and eta = 100. The model name is "MyNewModel." 
  Dim ModelType As ModelTypeEnum
  Dim ModelCategory As ModelCategoryEnum
  Dim ModelName As String
  Dim ModelParams(2) As Double
 
  ModelType = ModelTypeEnum_Weibull2
  ModelCategory = ModelCategoryEnum_Reliability
  ModelName = "MyNewModel"
  ModelParams(0) = 1
  ModelParams(1) = 100

  Dim newModel As New cModel
  Call newModel.SetModel(ModelType, ModelCategory, ModelName, ModelParams)

 'Add the new model to project #1. 
  MyRepository.Project.SetCurrentProject(1)   
  Call MyRepository.Model.AddModel(newModel)
VB.NET

 'Declare a new Repository object and connect to a Synthesis repository. 
  Dim MyRepository As New Repository
  MyRepository.ConnectToAccessRepository("C:\RSRepository1.rsr10")
 
 'Create a new model. The following example creates a 2-parameter Weibull reliability model, 
 'with beta = 1 and eta = 100. The model name is "MyNewModel." 
  Dim newModel As New cModel(ModelTypeEnum.Weibull2, ModelCategoryEnum.Reliability, "MyNewModel", 1, 100)

 'Add the new model to project #1. 
  MyRepository.Project.SetCurrentProject(1)   
  MyRepository.Model.AddModel(newModel)