Difference between revisions of "Add New Synthesis Resources to a Repository/VBA"

From ReliaWiki
Jump to navigation Jump to search
 
Line 27: Line 27:
 
  {{APIComment|'Connect to a Synthesis repository and project.}}
 
  {{APIComment|'Connect to a Synthesis repository and project.}}
 
   {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
 
   {{APIPrefix|Dim}} MyRepository {{APIPrefix|As New}} Repository
   MyRepository.ConnectToRepository({{APIString|"C:\RSRepository1.rsr10"}}){{APIComment|'Replace with name and path to test repository.}}
+
   MyRepository.ConnectToRepository({{APIString|"C:\RSRepository1.rsr11"}}){{APIComment|'Replace with name and path to test repository.}}
 
   MyRepository.Project.SetCurrentProject(1){{APIComment|'Replace with the object ID of test project.}}  
 
   MyRepository.Project.SetCurrentProject(1){{APIComment|'Replace with the object ID of test project.}}  
 
   
 
   

Latest revision as of 18:08, 3 April 2017

APIWiki.png



Tutorial: Add a New Synthesis Resource to a Repository

Below is the VBA version of the tutorial.

VBA

Sub Main()

 'Declare a new cModel object. 
  Dim Amodel As New cModel

 'Define the model. 
  Dim ModelType As ModelTypeEnum
  Dim ModelCategory As ModelCategoryEnum
  Dim ModelName As String
  Dim ModelParams(1) As Double

  ModelType = ModelTypeEnum_Weibull2
  ModelCategory = ModelCategoryEnum_Reliability
  ModelName = "MyNewModel"
  ModelParams(0) = 1
  ModelParams(1) = 100
 
  Call AModel.SetModel(ModelType, ModelCategory, ModelName, ModelParams)

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

 'Send the model to the project. 
  Call MyRepository.Model.AddModel(AModel)

End Sub