Edit Existing Synthesis Resources/VBA: Difference between revisions

From ReliaWiki
Jump to navigation Jump to search
(Created page with '{{Template:API}} ==Tutorial: Edit an Existing Synthesis Resource== Below is the VBA version of the tutorial. '''VBA''' Sub Main() …')
 
No edit summary
Line 16: Line 16:
   {{APIPrefix|Dim}} Amodel {{APIPrefix|As New}} cModel
   {{APIPrefix|Dim}} Amodel {{APIPrefix|As New}} cModel
    
    
  {{APIComment|'Retrieve a model from the repository.}}
  {{APIComment|'Retrieve a model from the project.}}
   {{APIPrefix|Set}} AModel = MyRepository.Model.GetModel(21){{APIComment|'Replace with the object ID of test model.}}
   {{APIPrefix|Set}} AModel = MyRepository.Model.GetModel(21){{APIComment|'Replace with the object ID of test model.}}
   
   
  {{APIComment|'Edit the model's name, description and part number.}}
{{APIComment|'Edit the model's name, description and part number.}}
   Amodel.Name = {{APIString|"MyNewModel_Updated"}}
   Amodel.Name = {{APIString|"MyNewModel_Updated"}}
   Amodel.ItemDescription = {{APIString|"A specific type of light bulb."}}
   Amodel.ItemDescription = {{APIString|"A specific type of light bulb."}}
   Amodel.ItemPartNumber = {{APIString|"PN5461"}}   
   Amodel.ItemPartNumber = {{APIString|"PN5461"}}   
    
    
  {{APIComment|'Send the changes to the Synthesis repository.}}
  {{APIComment|'Send the changes to the project.}}
   {{APIPrefix|Call}} MyRepository.Model.UpdateModel(AModel)
   {{APIPrefix|Call}} MyRepository.Model.UpdateModel(AModel)
   
   
  End Sub
  End Sub

Revision as of 16:26, 29 April 2016

APIWiki.png



Tutorial: Edit an Existing Synthesis Resource

Below is the VBA version of the tutorial.

VBA

Sub Main()

 'Connect to a Synthesis repository and project. 
  Dim MyRepository As New Repository
  MyRepository.ConnectToRepository("C:\RSRepository1.rsr10") 'Replace with name and path to test repository. 
  MyRepository.Project.SetCurrentProject(1) 'Replace with the object ID of test project. 

 'Declare a new cModel object. 
  Dim Amodel As New cModel
 
 'Retrieve a model from the project. 
  Set AModel = MyRepository.Model.GetModel(21) 'Replace with the object ID of test model. 

 'Edit the model's name, description and part number. 
  Amodel.Name = "MyNewModel_Updated"
  Amodel.ItemDescription = "A specific type of light bulb."
  Amodel.ItemPartNumber = "PN5461"   
 
 'Send the changes to the project. 
  Call MyRepository.Model.UpdateModel(AModel)

End Sub