Solid Edge Framework Type Library
Add Method
Specifies the variable to be added to the list.
Description
Adds an occurrence of the referenced object.
Syntax
Visual Basic
Public Sub Add( _
   ByVal variable As Variant _
) 
Parameters
variable
Specifies the variable to be added to the list.
Example
Private Sub Form_Load()
    Dim objApp As SolidEdgeframework.Application
    Dim objDoc As SolidEdgepart.PartDocument
    Dim objVars As SolidEdgeframework.Variables
    Dim objVar1 As SolidEdgeframework.variable
    Dim objVar2 As SolidEdgeframework.variable
    Dim objVarList As SolidEdgeframework.VariableList
    Dim strVar1 As String
    Dim strFormula1 As String
    Dim strVar2 As String
    Dim strFormula2 As String
    ' Report errors
    Const PI = 3.14159265358979
    ' Create/get the application with specific settings
    On Error Resume Next
    Set objApp = GetObject(, "SolidEdge.Application")
    If Err Then
        Err.Clear
        Set objApp = CreateObject("SolidEdge.Application")
        Set objDoc = objApp.Documents.Add("SolidEdge.PartDocument")
        objApp.Visible = True
    Else
        Set objDoc = objApp.ActiveDocument
    End If
    ' Open the TestCase file
    Set objDoc = objApp.Documents.Open(Filename:="T:\vbtests\TestCases\Variables.par")
    ' Add a new Variable to the already existing Variables
    Set objVars = objDoc.Variables
    ' Set the Variable name and Formula
    strVar1 = "MyVar1"
    strFormula1 = "2*Height"
    Set objVar1 = objVars.Add(pName:=strVar1, pFormula:=strFormula1, UnitsType:=igUnitDistance)
    ' Query for the existing User created Variables
    Set objVarList = objVars.Query(pFindCriterium:="MyVar1")
    ' Add a new Variable
    ' Set the Variable name and Formula
    strVar2 = "MyVar2"
    strFormula2 = "4*Height"
    Set objVar2 = objVars.Add(pName:=strVar2, pFormula:=strFormula2, UnitsType:=igUnitDistance)
    ' Add another Variable to the List
    Call objVarList.Add(variable:=objVar2)
    ' USER DISPLAY
    ' Release objects
    Set objApp = Nothing
    Set objDoc = Nothing
    Set objVars = Nothing
    Set objVar1 = Nothing
    Set objVar2 = Nothing
    Set objVarList = Nothing
End Sub
See Also

VariableList Collection  | VariableList Members