APISynthesisResourcesTutorial3

 << Back to Quick Start Guide

Synthesis Resources Tutorial
 * 1) Connect to a Synthesis Repository and Project
 * 2) Create a New Synthesis Resource
 * 3) Update an Existing Resource
 * 4) Calculate Results from a Model

In this section, we'll update the properties of the model we've created in the previous section and also update its definition.

Part 3: Update an Existing Resource
1. Create a new module and add code to connect to the Synthesis repository and project.

VBA|VB.NET MyRepository Repository MyRepository.ConnectToRepository MyRepository.Project.SetCurrentProject(1)

2. Next, use the  method to the retrieve the model (called "MyNewModel") from the repository. The following code assumes that the model's ID number is 21.

VBA Amodel cModel AModel = MyRepository.Model.GetModel(21)

VB.NET Amodel cModel AModel = MyRepository.Model.GetModel(21)

3. Let's update the model's properties. Use the following code to add a description and part number for the model.

VBA|VB.NET Amodel.ItemDescription = Amodel.ItemPartNumber =

4. Let's also update the model's definition by changing its name to "MyNewModel_Updated" and the values of beta &#61; 2 and eta &#61; 150. Use the  method to define the model. In VB.NET, you can use an in-line parameter list to define the values of the parameters.

VBA ModelParams(1) Double ModelParams(0) = 2 ModelParams(1) = 150 AModel.SetModel(ModelTypeEnum_Weibull2, ModelCategoryEnum_Reliability,, ModelParams)

VB.NET AModel.SetModel(ModelTypeEnum.Weibull2, ModelCategoryEnum.Reliability,, {2, 150}) 5. Use the  method to apply the changes to the model.

VBA MyRepository.Model.UpdateModel(AModel)

VB.NET MyRepository.Model.UpdateModel(AModel)

Test the Code
Below are the VBA and VB.NET code lists for this example. On the Debug menu, click Start to run the application, and then check the project's Resource Manager to verify that the model's name has been changed to "MyNewModel_Updated" and that beta &#61; 2 and eta &#61; 150.

VBA Sub Main MyRepository Repository MyRepository.ConnectToRepository MyRepository.Project.SetCurrentProject(1) Amodel cModel AModel = MyRepository.Model.GetModel(21) Amodel.ItemDescription = Amodel.ItemPartNumber = ModelParams(1) Double ModelParams(0) = 2 ModelParams(1) = 150 AModel.SetModel(ModelTypeEnum_Weibull2, ModelCategoryEnum_Reliability,, ModelParams) MyRepository.Model.UpdateModel(AModel) End Sub

VB.NET Sub Main MyRepository Repository MyRepository.ConnectToRepository MyRepository.Project.SetCurrentProject(1) Amodel cModel AModel = MyRepository.Model.GetModel(21) Amodel.ItemDescription = Amodel.ItemPartNumber = AModel.SetModel(ModelTypeEnum.Weibull2, ModelCategoryEnum.Reliability,, {2, 150}) MyRepository.Model.UpdateModel(AModel) End Sub