cModel.SetModel

From ReliaWiki
Jump to navigation Jump to search
APIWiki.png


Member of: SynthesisAPI.cModel


Sets the model type, category, name and parameters of an associated cModel object.

Syntax

.SetModel(ModelType, ModelCategory, ModelName, ByRef ModelParams())

Parameters

ModelType

Required. The model type (e.g., 2-parameter Weibull). Can be any ModelTypeEnum constant.

ModelCategory

Required. The model category (e.g., reliability model). Can be any ModelCategoryEnum constant.

ModelName

Required. String. The model name.

ModelParams()

Required. Double. An array of the model's parameters.


Example

VBA

 ... 

 'Create a new model. The following example creates a 2-parameter Weibull reliability model, 
 'with beta = 1 and eta = 100. The model name is "MyNewModel." 
  Dim ModelType As ModelTypeEnum
  Dim ModelCategory As ModelCategoryEnum
  Dim ModelName As String
  Dim ModelParams(2) As Double
 
  ModelType = ModelTypeEnum_Weibull2
  ModelCategory = ModelCategoryEnum_Reliability
  ModelName = "MyNewModel"
  ModelParams(0) = 1
  ModelParams(1) = 100

  Dim newModel As New cModel
  Call newModel.SetModel(ModelType, ModelCategory, ModelName, ModelParams)

 'Add the new model to project #1. 
  MyRepository.Project.SetCurrentProject(1)   
  Call MyRepository.Model.AddModel(newModel)

 'To replace an existing model, first get the model to be replaced. 
 'The following example assumes that model with ID#47 exists in the repository. 
  Dim AModel As New cModel
  Set AModel = MyRepository.Model.GetModel(47)

 'Apply the definitions to the model. 
  Call AModel.SetModel(ModelType, ModelCategory, ModelName, ModelParams)

 'Replace the model.    
  Call MyRepository.Model.UpdateModel(AModel)
VB.NET

 ... 

 'Create a new model. The following code creates a 2-parameter Weibull reliability model, 
 'with beta 1 and eta 100. The model name is "MyNewModel." 
  Dim ModelParams(1) As Double
  ModelParams(0) = 1
  ModelParams(1) = 100
  Dim newModel As New cModel(ModelTypeEnum.Weibull2,ModelCategoryEnum.Reliability, "MyNewModel", ModelParams) 

 'Add the new model to project #1. 
  MyRepository.Project.SetCurrentProject(1)   
  MyRepository.Model.AddModel(newModel)

 'To replace an existing model, first get the model to be replaced. 
 'The following example assumes that model with ID#47 exists in the repository. 
  Dim AModel As New cModel
  AModel = MyRepository.Model.GetModel(47)

 'Apply the definitions to the model. 
  AModel.SetModel(ModelTypeEnum.Weibull2,ModelCategoryEnum.Reliability, "UpdatedModel", ModelParams)

 'Replace the model.    
  MyRepository.Model.UpdateModel(AModel)