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 learn how to update the properties of the model we've created in the previous section.

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, retrieve the model from the repository so we can edit it. Use the  method to the retrieve the model (called "MyNewModel"). 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. Edit the model's properties. Use the following code to edit the model's name, description and part number.

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

4. 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 properties have been updated. (You may need to display the Description and Part Number columns of the Resource Manager by right-clicking a column header and choosing Select Columns.)

VBA Sub Main MyRepository Repository MyRepository.ConnectToRepository MyRepository.Project.SetCurrentProject(1) Amodel cModel AModel = MyRepository.Model.GetModel(21) Amodel.Name = Amodel.ItemDescription = Amodel.ItemPartNumber = MyRepository.Model.UpdateModel(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 AModel = MyRepository.Model.GetModel(21) Amodel.Name = Amodel.ItemDescription = Amodel.ItemPartNumber = MyRepository.Model.UpdateModel(AModel)

You can use a similar approach to update the properties of other types of Synthesis repositories. For example, to update the properties of an existing URD, you would use the  method to retrieve the URD from the repository, and then use the   method to apply the changes.