Repository.Model.AddModel: Difference between revisions

From ReliaWiki
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
{{Template:APIClass|Repository Class|Repository}}
{{Template:APIBreadcrumb|10|Repository}}
{{Template:Repository.AddModel.Cmt}} {{Template:BooleanReturn.Cmt}}
{{Template:API}}
Creates a new model and saves it in the current project. Returns a '''Boolean''' value; when true, indicates that the model was successfully created and saved in the project.  


== Syntax==
== Syntax ==
*AddModel( m {{APIPrefix|As}}[[cModel Class|cModel]] ){{APIPrefix|As Boolean}}
''object''.'''Model.AddModel(''m'')'''


Parameters
where ''object'' is a variable that represents a Repository object.
:''m'': The [[cModel Class|cModel]] to add.


== Usage Example ==
=== Parameters ===
In this example, a new model is created and added to a repository.
{| {{APITable}}
  {{APIComment|'Declare a new repository connection object.}}
|-
  Dim MyRepository As New Repository
|m{{APIParam|Required}}||The '''[[CModel Class|cModel]]''' object to be added.
 
|}
  {{APIComment|'Connect to the Synthesis repository.}}
 
  Dim Success As Boolean = False
 
  Success = MyRepository.ConnectToRepository("RepositoryFileNamePath")
== Example ==
 
This example creates a new model in the first available project in a Synthesis repository.
  {{APIComment|'Set a first available project as current.}}
  '''VB.NET'''
   MyRepository.Project.SetCurrentProject(0)
  {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
  {{APIComment|...'Add code to connect to a Synthesis repository.}}
  {{APIComment|'Declare a new model.}}
   {{APIPrefix|Dim}} newModel {{APIPrefix|As New}} cModel(ModelTypeEnum.Weibull2, ModelCategoryEnum.Reliability, {{APIString|"MyNewModel"}}, 1, 100)
   
   
  {{APIComment|'Declare a new model using an in-line parameter list. See [[cModel Class|cModel]].}}
  {{APIComment|'Add the model to project #1. The model will be available in the Synthesis repository upon refresh.}}
  Dim newModel As New cModel(ModelTypeEnum.Weibull2, ModelCategoryEnum.Reliability, "NewModel1", 1, 100)
  MyRepository.Project.SetCurrentProject(1)   
 
  MyRepository.Model.AddModel(newModel)
{{APIComment|'Add model to the current project.}}
   Dim SuccessAddModel As Boolean = False
  SuccessAddModel = MyRepository.Model.AddModel(newModel)
 
{{APIComment|'Disconnect from the repository.}}
  MyRepository.DisconnectFromRepository()

Revision as of 17:51, 14 July 2015

Member of: SynthesisAPI10Repository

APIWiki.png


Creates a new model and saves it in the current project. Returns a Boolean value; when true, indicates that the model was successfully created and saved in the project.

Syntax

object.Model.AddModel(m)

where object is a variable that represents a Repository object.

Parameters

Name Description
mborder="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse; text-align: left; cellborder"
Name Status The cModel object to be added.


Example

This example creates a new model in the first available project in a Synthesis repository.

VB.NET

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

 'Declare a new model. 
 Dim newModel As New cModel(ModelTypeEnum.Weibull2, ModelCategoryEnum.Reliability, "MyNewModel", 1, 100)

 'Add the model to project #1. The model will be available in the Synthesis repository upon refresh. 
  MyRepository.Project.SetCurrentProject(1)   
  MyRepository.Model.AddModel(newModel)