Add New Synthesis Resources to a Repository

 << Back to API Tutorials

Basics
 * 1) Connect or Disconnect from a Synthesis Repository
 * 2) Add New Synthesis Resources to a Repository
 * 3) Edit Existing Synthesis Resources
 * 4) Calculate Results from a Model

In this tutorial, you'll learn how to create a Synthesis resource and add it to a Synthesis repository. We'll use the  class for this example.

Create a New Model
1. Create a new module and begin by connecting to a Synthesis repository and project. The following code assumes that a standard repository called "RSRepository1.rsr10" exists in the C drive.

MyRepository Repository MyRepository.ConnectToRepository MyRepository.Project.SetCurrentProject(1)

2. Use the constructor in the  class to create a model. Then use the  method to define the model. Note that for VB.NET, you can use the parameterized contructor to create and define the model.

For this example, let's create a 2-parameter Weibull reliability model with beta 1 and eta 100. The model name is, "MyNewModel."

VBA Amodel cModel ModelType ModelTypeEnum ModelCategory ModelCategoryEnum ModelName String ModelParams(1) Double ModelType = ModelTypeEnum_Weibull2 ModelCategory = ModelCategoryEnum_Reliability ModelName = ModelParams(0) = 1 ModelParams(1) = 100 AModel.SetModel(ModelType, ModelCategory, ModelName, ModelParams)

VB.NET AModel cModel(ModelTypeEnum.Weibull2, ModelCategoryEnum.Reliability,, 1, 100) 3. Use the  method to save the new model to the repository.

VBA MyRepository.Model.AddModel(AModel)

VB.NET MyRepository.Model.AddModel(AModel)

Test the Code
Below are the complete code lists for this example. To test them, run the application by clicking Start on the Debug menu. Then in the Synthesis repository, open the project’s Resource Manager (Project > Synthesis> Resource Manager) and select the Models page. A model named "MyNewModel" should be on the list. (You may need to click the Refresh or Show All command to update the display.)

VBA Sub Main MyRepository Repository MyRepository.ConnectToRepository MyRepository.Project.SetCurrentProject(1) Amodel cModel ModelType ModelTypeEnum ModelCategory ModelCategoryEnum ModelName String ModelParams(1) Double ModelType = ModelTypeEnum_Weibull2 ModelCategory = ModelCategoryEnum_Reliability ModelName = ModelParams(0) = 1 ModelParams(1) = 100 AModel.SetModel(ModelType, ModelCategory, ModelName, ModelParams) MyRepository.Model.AddModel(AModel) End Sub

VB.NET SynthesisAPI Form1 Button1_Click(sender System.Object, e  System.EventArgs)  Button1.Click MyRepository Repository MyRepository.ConnectToRepository MyRepository.Project.SetCurrentProject(1) AModel cModel(ModelTypeEnum.Weibull2, ModelCategoryEnum.Reliability,, 1, 100) MyRepository.Model.AddModel(AModel)