Repository.Model.AddModel: Difference between revisions

From ReliaWiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
<noinclude>{{Template:API}}{{Template:APIBreadcrumb|10|[[Repository Class|Repository]]}}</noinclude>
<noinclude>{{Template:API}}{{Template:APIBreadcrumb|10|.[[Repository Class|Repository]]}}</noinclude>


Saves a new [[CModel Class|cModel]] object to the Synthesis repository. Returns a '''Boolean''' value; when true, indicates that the model now exists in the repository.  
 
Saves a new [[CModel Class|cModel]] object to the current project. Returns a '''Boolean''' value; when true, indicates a successful save.  
<noinclude>
<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.)
== Syntax ==
== Syntax ==
''object''.'''Model.AddModel(''m'')'''
'''.Model.AddModel'''(''m'')
 
where ''object'' is a variable that represents a Repository object.


=== Parameters ===
=== Parameters ===
{| {{APITable}}
''m''
|-
:The [[CModel Class|cModel]] object to be added. (Required)
|m{{APIParam|Required}}||The [[CModel Class|cModel]] object to be added.
|}




== Example ==
== Example ==
This example creates a new model in the first available project in a Synthesis repository.
This example creates a new model resource, and then saves it in the first available project in a Synthesis repository.
  '''VBA'''
  '''VBA'''
{{APIComment|'Add code to connect to a Synthesis repository.}}
   {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
   {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
{{APIComment|...'Add code to connect to a Synthesis repository.}}   
  {{APIComment|...}}
   
   
   
  {{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,}}
Line 43: Line 44:
  '''VB.NET'''
  '''VB.NET'''
   
   
  {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
{{APIComment|'Add code to connect to a Synthesis repository.}}
{{APIComment|...'Add code to connect to a Synthesis repository.}}   
  {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
  {{APIComment|...}}
   
   
   
  {{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,}}

Revision as of 18:10, 20 July 2015

APIWiki.png


Member of: SynthesisAPI10.Repository


Saves a new cModel object to the current project. Returns a Boolean value; when true, indicates a successful save.

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.)

Syntax

.Model.AddModel(m)

Parameters

m

The cModel object to be added. (Required)


Example

This example creates a new model resource, and then saves it in the first available project in a Synthesis repository.

VBA

 'Add code to connect to a Synthesis repository. 
  Dim MyRepository As New Repository
  ... 


 '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. The model will be visible in the Synthesis repository upon refresh. 
 MyRepository.Project.SetCurrentProject(1)   
 Call MyRepository.Model.AddModel(newModel)
VB.NET

 'Add code to connect to a Synthesis repository. 
  Dim MyRepository As New Repository
  ...   


 '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. The model will be visible in the Synthesis repository upon refresh. 
 MyRepository.Project.SetCurrentProject(1)   
 MyRepository.Model.AddModel(newModel)