Hide Table of Contents

Create Linear Dynamic Study Example (VBA)

This example shows how to create a linear dynamic study.

NOTE: To get persistent reference identifiers (PIDs) for model selections, you can use pidcollector.exe or IModelDocExtension::GetPersistReference3.

'----------------------------------------------------------------------------
' Preconditions:
' 1. Add the SolidWorks Simulation as an add-in
'    (in SolidWorks, click Tools > Add-ins > SolidWorks Simulation).
' 2. Add the SolidWorks Simulation type library as a reference
'    (in the IDE, click Tools > References > SolidWorks
'    Simulation version type library
).
' 3. Modify install_dir to point to your SolidWorks installation directory.
'
' Postconditions:
' 1. Linear_Dynamic_1.sldprt is opened.
' 2. A linear dynamic study is created.
' 3. An harmonic analysis is run.
' 4. The Dynamic_Harmonic simulation study tree contains the following:
'    * Nonlinear_Static_2 (shell)
'    * Connections
'    * Fixtures
'      ** Fixed-1
'      ** Fixed-2
'    * External Loads
'      ** Pressure-1
'      ** Base Excitation-1
'      ** Distributed Mass-1
'    * Mesh
'    * Damping (-Modal damping-)
'    * Result Options
'    * Results
'      ** Stress1 (-vonMises-)
'      ** Displacement1 (-Res disp-)
'      ** Velocity1 (-VX-)
' 5. Right-click on the Stress1 or Displacement1 plot in the Results folder
'    and select Show to plot the results in color in the graphics area.
' 6. Inspect the Immediate Window for:
'    * Dynamic study options
'    * Study result options
'    * Uniform base excitation data
'    * Total distributed mass
'    * Worst Jacobian ratio
'    * Study results
'      * Min/Max URES resultant displacements at maximum solution step
'        ** Node with minimum value
'        ** Minimum value
'        ** Node with maximum value
'        ** Maximum value
'      * Min/Max von Mises stresses at maximum solution step
'        ** Node with minimum value
'        ** Minimum value
'        ** Node with maximum value
'        ** Maximum value
'      * Min/Max velocities at maximum solution step
'        ** Node with minimum value
'        ** Minimum value
'        ** Node with maximum value
'        ** Maximum value
'      * Min/Max accelerations at maximum solution step
'        ** Node with minimum value
'        ** Minimum value
'        ** Node with maximum value
'        ** Maximum value
' 7. Inspect c:\temp for saved solution step, displacement, velocity,
'    and stress result files.
'
' NOTES: Because the model is used elsewhere,
'        do not save any changes when closing it.
'----------------------------------------------------------------------------

Option Explicit

Sub main()
   

    Dim SwApp           As SldWorks.SldWorks
    Dim Part            As SldWorks.ModelDoc2
    Dim COSMOSWORKS     As CosmosWorksLib.COSMOSWORKS
    Dim CWAddinCallBack As CosmosWorksLib.CWAddinCallBack
    Dim ActDoc          As CosmosWorksLib.CWModelDoc
    Dim StudyMngr       As CosmosWorksLib.CWStudyManager
    Dim Study           As CosmosWorksLib.CWStudy
    Dim ShellMgr        As CosmosWorksLib.CWShellManager
    Dim ShellMat        As CosmosWorksLib.CWMaterial
    Dim LBCMgr          As CosmosWorksLib.CWLoadsAndRestraintsManager
    Dim CWBaseExcitationU   As CosmosWorksLib.CWBaseExcitation
    Dim CWDistribMass   As CosmosWorksLib.CWDistributedMass
    Dim CWBaseExcitationEntity   As Object
    Dim CWDirectionEntity As Object
    Dim longstatus      As Long
    Dim longwarnings    As Long
    Dim errCode         As Long
    Dim boolstatus      As Boolean
    Dim nStep           As Long
    Dim pDisp5      As Object
    Dim DispArray1 As Variant, DispArray2 As Variant, DispArray3 As Variant, DispArray4 As Variant
    Dim Disp As Variant, Stress As Variant, Velocity As Variant, Acceleration As Variant, Strain As Variant
    Dim sStudyName As String
    Dim ResultOptions As CosmosWorksLib.CWStudyResultOptions
    Dim DampingOptions As CosmosWorksLib.CWDampingOptions
    Dim DampingRatios As Variant
    Dim i As Long
   

    'Tolerances and baselines
    Const MeshEleSize   As Double = 26.5868077635828 'mm
    Const MeshTol       As Double = 1.32934038817914 'mm
  

    'PID to call
    Dim PIDCollection As New Collection
    Set PIDCollection = PIDInitializer()
   

    'Connect to SW
    Set SwApp = Application.SldWorks
    If SwApp Is Nothing Then Exit Sub

    'Open document
    Set Part = SwApp.OpenDoc6("install_dir\samples\tutorial\api\LinearDynamic.SLDPRT", swDocPART, 1, "", longstatus, longwarnings)
    If Part Is Nothing Then ErrorMsg SwApp, "Failed to open LinearDynamic.SLDPRT."
       

    'Addin callback
    Set CWAddinCallBack = SwApp.GetAddInObject("SldWorks.Simulation")
    If CWAddinCallBack Is Nothing Then ErrorMsg SwApp, "Failed to get CWAddinCallBack object."
    Set COSMOSWORKS = CWAddinCallBack.COSMOSWORKS
    If COSMOSWORKS Is Nothing Then ErrorMsg SwApp, "Failed to get COSMOSWORKS object."
   

    'Get active document
    Set ActDoc = COSMOSWORKS.ActiveDoc()
    If ActDoc Is Nothing Then ErrorMsg SwApp, "Failed to get active document."
   

    'Create a dynamic harmonic study
    Set StudyMngr = ActDoc.StudyManager()
    If StudyMngr Is Nothing Then ErrorMsg SwApp, "Failed to get StudyManager object."
  

    sStudyName = "Dynamic_Harmonic"
    Set Study = StudyMngr.CreateNewStudy3(sStudyName, swsAnalysisStudyTypeDynamic, swsDynamicHarmonic, errCode)
   

    Debug.Print "Linear dynamic study with harmonic analysis"
    Debug.Print ""
    Debug.Print "Dynamic study options..."
    Dim DynStudyOptions As CosmosWorksLib.CWDynamicStudyOptions
    Set DynStudyOptions = Study.DynamicStudyOptions
    Dim freqOption As Long
    Dim freqValue As Double
    Dim bChecked As Long
    DynStudyOptions.GetFrequencyOption freqOption, freqValue
    Debug.Print "  Frequency option (as defined in swsFrequencyStudyOption_e): " & freqOption
    Debug.Print "  No. of frequencies or upper-bound frequency: " & freqValue
    DynStudyOptions.GetFrequencyShiftOption bChecked, freqValue
    Debug.Print "  Is frequency shift enabled (0=no, 1=yes)? " & bChecked
    Debug.Print "  Frequency shift: " & freqValue
    DynStudyOptions.IncompatibleBondingOption = 0 ' automatic
    DynStudyOptions.UseSoftSpring = 0 ' do not use soft springs to stabilize model
    DynStudyOptions.ResultFolderPath = "c:\temp"
    DynStudyOptions.SolverType = 2 ' FFEPlus
    Debug.Print "  Harmonic bandwidth: " & DynStudyOptions.HarmonicBandwidth
    Debug.Print "  Harmonic frequency lower limit: " & DynStudyOptions.HarmonicFrequencyLowerLimit
    Debug.Print "  Harmonic frequency upper limit: " & DynStudyOptions.HarmonicFrequencyUpperLimit
    Debug.Print "  Harmonic frequency units (as defined in swsFrequencyUnit_e): " & DynStudyOptions.HarmonicFrequencyUnits
    Debug.Print "  Harmonic interpolation (as defined in swsInterpolationType_e): " & DynStudyOptions.HarmonicInterpolation
    Debug.Print "  Harmonic number of points for each frequency: " & DynStudyOptions.HarmonicNoOfPoints
    Debug.Print ""
   

    'Set study result options
    Debug.Print "Study result options..."
    Set ResultOptions = Study.StudyResultOptions
    ResultOptions.SaveResultsForSolutionStepsOption = 1 ' save solution step results
    ResultOptions.SaveDisplacementsAndVelocitiesOption = 1 ' save displacements and velocities
    ResultOptions.SaveStresses = 1 ' save stresses
    ' Solution step set #1
    errCode = ResultOptions.SetSolutionStepsSetInformation(1, 10, 100, 3)
    Debug.Print "  Set solution steps set #1 (10-100, inc=3)? (0=success): " & errCode
    ' Solution step set #3
    errCode = ResultOptions.SetSolutionStepsSetInformation(3, 100, 1000, 5)
    Debug.Print "  Set solution steps set #3 (100-1000, inc=5)? (0=success): " & errCode
    Debug.Print ""
   

    'Set damping options
    Set DampingOptions = Study.DampingOptions
    DampingOptions.DampingType = 0 'Modal damping
    DampingRatios = Array(1, 5, 3.45, 6, 15, 15, 16, 25, 34.5)
    errCode = DampingOptions.SetDampingRatios(3, (DampingRatios))
    DampingOptions.ComputeFromMaterialDamping = 0 ' do not use the material damping ratio
   

    'Create variant arrays
    DispArray1 = Array(SelectByPID(Part, "selection1", PIDCollection))
    DispArray2 = Array(SelectByPID(Part, "selection1", PIDCollection))
    DispArray3 = Array(SelectByPID(Part, "selection2", PIDCollection))
    DispArray4 = Array(SelectByPID(Part, "selection3", PIDCollection), SelectByPID(Part, "selection4", PIDCollection))
   

    'Get Edge-1 by persistent ID
    Set CWBaseExcitationEntity = SelectByPID(Part, "selection3", PIDCollection)
   

    'Get Axis1 by persistent ID
    Set CWDirectionEntity = SelectByPID(Part, "selection5", PIDCollection)
    Set pDisp5 = SelectByPID(Part, "selection5", PIDCollection)
   

    'Add materials
    Set ShellMgr = Study.ShellManager
    If ShellMgr Is Nothing Then ErrorMsg SwApp, "Failed to get ShellMgr object."
   

    Dim CWFeatObj1 As CosmosWorksLib.CWShell
    Set CWFeatObj1 = ShellMgr.GetShellAt(0, errCode)
    If errCode <> 0 Then ErrorMsg SwApp, "Failed to get shell component."
    Set ShellMat = CWFeatObj1.GetDefaultMaterial
    ShellMat.MaterialUnits = 0
    Call ShellMat.SetPropertyByName("EX", 2000000000000#, 0)
    Call ShellMat.SetPropertyByName("NUXY", 0.25, 0)
    errCode = CWFeatObj1.SetShellMaterial(ShellMat)
    If errCode <> 0 Then ErrorMsg SwApp, "Failed to apply material."
  

    Call CWFeatObj1.ShellBeginEdit
    CWFeatObj1.Formulation = 1 ' thick shell
    CWFeatObj1.ShellUnit = 1 ' centimeters
    CWFeatObj1.ShellThickness = 5 ' 5 cm
    CWFeatObj1.ShellOffsetOption = 3 ' specify reference surface
    CWFeatObj1.ShellOffsetValue = 0.3
    errCode = CWFeatObj1.ShellEndEdit
    If errCode <> 0 Then ErrorMsg SwApp, "Failed to create shell."
    Set CWFeatObj1 = Nothing
   

    'Get loads and restraints manager
    Set LBCMgr = Study.LoadsAndRestraintsManager
    If LBCMgr Is Nothing Then ErrorMsg SwApp, "Failed to get LoadsAndRestraintsManager."
   

    'Create normal pressure
    Dim CWFeatObj2 As CosmosWorksLib.CWPressure
    Set CWFeatObj2 = LBCMgr.AddPressure(0, (DispArray2), Nothing, errCode)
    If errCode <> 0 Then ErrorMsg SwApp, "Failed to create normal pressure."
    Call CWFeatObj2.PressureBeginEdit
    CWFeatObj2.Unit = 0
    CWFeatObj2.Value = 4000000#
    errCode = CWFeatObj2.PressureEndEdit
    If errCode <> 0 Then ErrorMsg SwApp, "Failed to apply normal pressure value."
    Set CWFeatObj2 = Nothing
   

    'Add Restraints
    Dim CWFeatObj3 As CosmosWorksLib.CWRestraint
    Set CWFeatObj3 = LBCMgr.AddRestraint(0, (DispArray3), pDisp5, errCode)
    If errCode <> 0 Then ErrorMsg SwApp, "Failed to create first restraint."
    Call CWFeatObj3.RestraintBeginEdit
    Call CWFeatObj3.SetTranslationComponentsValues(0, 0, 1, 0#, 0#, 0#)
    Call CWFeatObj3.SetRotationComponentsValues(0, 0, 0, 0#, 0#, 0#)
    CWFeatObj3.Unit = 2
    errCode = CWFeatObj3.RestraintEndEdit
    If errCode <> 0 Then ErrorMsg SwApp, "First RestraintEndEdit failed."
   

    Set CWFeatObj3 = LBCMgr.AddRestraint(0, (DispArray4), pDisp5, errCode)
    If errCode <> 0 Then ErrorMsg SwApp, "Failed to create second restraint."
    Call CWFeatObj3.RestraintBeginEdit
    Call CWFeatObj3.SetTranslationComponentsValues(0, 1, 0, 0#, -0#, 0#)
    Call CWFeatObj3.SetRotationComponentsValues(1, 0, 1, -0#, 0#, -0#)
    CWFeatObj3.Unit = 2
    errCode = CWFeatObj3.RestraintEndEdit
    If errCode <> 0 Then ErrorMsg SwApp, "Second RestraintEndEdit failed."
    Set CWFeatObj3 = Nothing
   

    'Add uniform base excitation
    Set CWBaseExcitationU = LBCMgr.AddUniformBaseExcitation(2, CWBaseExcitationEntity, 1, 1, 2.3, 1, 3.4, 1, 4.5, errCode)
    If errCode <> 0 Then ErrorMsg SwApp, "Adding uniform base excitation failed."
   

    Debug.Print "Uniform base excitation type (as defined in swsBaseExcitationType_e): " & CWBaseExcitationU.BaseExcitationType
    Dim bdir1 As Long, bdir2 As Long, bdir3 As Long
    CWBaseExcitationU.GetExcitationDirections bdir1, bdir2, bdir3
    Debug.Print "Excitation in..."
    Debug.Print "  Direction 1 (1=true)? " & bdir1
    Debug.Print "  Direction 2 (1=true)? " & bdir2
    Debug.Print "  Direction 3 (1=true)? " & bdir3
    Dim dval1 As Double, dval2 As Double, dval3 As Double
    CWBaseExcitationU.GetExcitationDirectionValues dval1, dval2, dval3
    Debug.Print "Excitation value in swsUnit_e units..."
    Debug.Print "  Direction 1: " & dval1
    Debug.Print "  Direction 2: " & dval2
    Debug.Print "  Direction 3: " & dval3
    Dim curveData As Variant
    curveData = CWBaseExcitationU.GetTimeOrFrequencyCurve 'variation with frequency data
    Debug.Print "Acceleration excitation variation with frequency data"
    Debug.Print "(number of points, x1, y1, x2, y2, ...xn, yn):"
    For i = 0 To UBound(curveData)
        Debug.Print curveData(i)
    Next
    Debug.Print "Phase angle: " & CWBaseExcitationU.PhaseAngle
    Debug.Print "Phase angle unit (as defined in swsPhaseAngleUnit_e): " & CWBaseExcitationU.PhaseAngleUnit
    Debug.Print "Units (depends on type of base excitation): " & CWBaseExcitationU.Unit
    Debug.Print ""
   

    'Add distributed mass
    Set CWDistribMass = LBCMgr.AddDistributedMass((DispArray2), 0, 1, errCode)
    Debug.Print "Total distributed mass: " & CWDistribMass.TotalMass
    Debug.Print "  Units (swsUnitSystem_e): " & CWDistribMass.Units
    Debug.Print ""
   

    'Create mesh
    Dim CWFeatObj4 As CosmosWorksLib.CWMesh
    Set CWFeatObj4 = Study.Mesh
    If CWFeatObj4 Is Nothing Then ErrorMsg SwApp, "Failed to create Mesh object"
    CWFeatObj4.MesherType = 0
    CWFeatObj4.Quality = 1
   

    errCode = Study.CreateMesh(0, MeshEleSize, MeshTol)
    If errCode <> 0 Then ErrorMsg SwApp, "Failed to create Mesh."
    Debug.Print "Worst Jacobian ratio for the mesh: " & CWFeatObj4.GetWorstJacobianRatio
    Debug.Print ""
   

    'Run analysis
    errCode = Study.RunAnalysis
    If errCode <> 0 Then ErrorMsg SwApp, "Analysis failed with error code " & errCode & " - " & ProcErrCode(errCode)
   

    'Get results
    Dim CWFeatObj5 As CosmosWorksLib.CWResults
    Set CWFeatObj5 = Study.Results
    If CWFeatObj5 Is Nothing Then ErrorMsg SwApp, "Failed to get Results object."
  

    Debug.Print "Study results..."
    nStep = CWFeatObj5.GetMaximumAvailableSteps
    Debug.Print "  Maximum available steps: " & nStep
   

    'Get algebraic minimum/maximum resultant displacements
    Disp = CWFeatObj5.GetMinMaxDisplacement(3, nStep, Nothing, 0, errCode)
    If errCode <> 0 Then ErrorMsg SwApp, "Failed to get displacement results."
    Debug.Print "  Min/Max URES Resultant Displacements (Node, Min, Node, Max):"
    For i = 0 To UBound(Disp)
        Debug.Print Disp(i)
    Next
    Debug.Print ""
   

    'Get algebraic minimum/maximum Von Mises stresses
    Stress = CWFeatObj5.GetMinMaxStress(9, 0, nStep, Nothing, 3, errCode)
    If errCode <> 0 Then ErrorMsg SwApp, "Failed to get stress results."
    Debug.Print "  Algebraic Min/Max von Mises Stresses (Node, Min, Node, Max):"
    For i = 0 To UBound(Stress)
        Debug.Print Stress(i)
    Next
    Debug.Print ""
   

    'Get algebraic minimum/maximum velocities
    Velocity = CWFeatObj5.GetMinMaxVelocity(0, nStep, CWDirectionEntity, 0, errCode)
    If errCode <> 0 Then ErrorMsg SwApp, "Failed to get velocity results."
    Debug.Print "  Algebraic Min/Max Velocities (Node, Min, Node, Max):"
    For i = 0 To UBound(Velocity)
        Debug.Print Velocity(i)
    Next
    Debug.Print ""
   

    'Get algebraic minimum/maximum accelerations
    Acceleration = CWFeatObj5.GetMinMaxAcceleration(0, nStep, CWDirectionEntity, 0, errCode)
    If errCode <> 0 Then ErrorMsg SwApp, "Failed to get acceleration results."
    Debug.Print "  Algebraic Min/Max Accelerations (Node, Min, Node, Max):"
    For i = 0 To UBound(Acceleration)
        Debug.Print Acceleration(i)
    Next
   

    Set CWFeatObj5 = Nothing

End Sub

Sub ErrorMsg(SwApp As Object, Message As String)
    SwApp.SendMsgToUser2 Message, 0, 0
    SwApp.RecordLine "'*** WARNING - General"
    SwApp.RecordLine "'*** " & Message
    SwApp.RecordLine ""
End Sub

Function SelectByPID(Part As SldWorks.ModelDoc2, PIDName As String, PIDCollection As Collection) As Object
    Dim PID()       As Byte
    Dim PIDVariant  As Variant
    Dim PIDString   As String
    Dim EntityType  As Long
    Dim i           As Integer
    Dim SelObj      As Object
   

    'Get the string from the collection
    PIDString = ""
    PIDString = PIDCollection.Item(PIDName)
   

    'Parse the string into an array
    PIDVariant = Split(PIDString, ",")
    ReDim PID(UBound(PIDVariant))
   

    'Change to a byte array
    For i = 0 To (UBound(PIDVariant) - 1)
        PID(i) = PIDVariant(i)
    Next i
   

    'Select the entity
    Set SelObj = Part.Extension.GetObjectByPersistReference((PID))
    Set SelectByPID = SelObj
    Set SelObj = Nothing
End Function

Function PIDInitializer() As Collection
   

    Dim PIDCollection As New Collection
    Dim selection1 As String
    Dim selection2 As String
    Dim selection3 As String
    Dim selection4 As String
    Dim selection5 As String

    'Pie face
    selection1 = "68,20,0,0,3,0,0,0,255,254,255,0,0,0,0,0,255,255,1,0,11,0,109,111,70,97,99,101,82,101,102,95,99,1,0,0,0,0,0,0,0,5,0,0,0,4,2,0,0,0,0,0,0,125,195,148,37,173,73,178,84,125,195,148,37,173,73,178,84,0,0,255,255,1,0,23,0,109,111,70,114,111,109,83,107,116,69,110,116,83,117,114,102,73,100,82,101,112,95,99,0,0,255,255,1,0,6,0,109,111,70,82,95,99,255,255,1,0,13,0,109,111,69,120,116,79,98,106,101,99,116,95,99,255,255,1,0,17,0,109,111,67,83,116,114,105,110,103,72,97,110,100,108,101,95,99,255,254,255,92,75,0,58,0,92,0,97,0,112,0,105,0,92,0,72,0,69,0,76,0,80,0,92,0,83,0,97,0,109,0,112,0,108,0,101,0,32,0,77,0,97,0,99,0,114,0,111,0,115,0,92,0,83,0,105,0,109,0,117,0,108,0,97,0,116,0,105,0,111,0,110,0,92,0,50,0,48,0,49,0,50,0,92,0,65,0,117,0,116,0,111,0,84,0,101,0,115,0,116,0,70,0,105,0,108,0,101,0,115,0,92,0,68,0,121,0,110,0,97,0,109,0,105,0,99,0,115,0,92,0,77,0,97,0,99,0,114,0,111,0,115,0,92,0,76,0,105,0,110,0,101,0,97,0,114,0,68,0,121,0,110,0,97,0,109,0,105,0,99,0,46,0,83,0,76,0,68,0,80"
    selection1 = selection1 & ",0,82,0,84,0,9,128,255,254,255,13,76,0,105,0,110,0,101,0,97,0,114,0,68,0,121,0,110,0,97,0,109,0,105,0,99,0,2,0,0,141,213,96,79,0,0,112,0,97,0,0,0,0,0,0,0,0,0,0,0,0,0,255,254,255,7,68,0,101,0,102,0,97,0,117,0,108,0,116,0,0,0,0,0,0,0,0,0,100,0,100,0,30,0,0,0,252,214,96,79,1,0,0,0,255,255,1,0,16,0,109,111,84,111,112,69,100,103,101,73,100,82,101,112,95,99,0,0,5,128,8,0,30,0,0,0,252,214,96,79,1,0,0,0,255,255,1,0,19,0,109,111,66,111,116,116,111,109,69,100,103,101,73,100,82,101,112,95,99,0,0,5,128,8,0,30,0,0,0,252,214,96,79,1,0,0,0,255,255,1,0,16,0,109,111,69,110,100,69,100,103,101,73,100,82,101,112,95,99,0,0,5,128,8,0,30,0,0,0,252,214,96,79,0,0,0,0,0,0,0,0,0,0,0,0,0,0"
    selection1 = selection1 & ",Type=1"

    'Pie curve Edge-1
    selection2 = "68,20,0,0,3,0,0,0,255,254,255,0,0,0,0,0,255,255,1,0,11,0,109,111,69,100,103,101,82,101,102,95,99,1,0,0,0,0,0,0,0,5,0,0,0,4,3,0,0,0,0,0,0,125,195,148,37,173,73,178,84,125,195,148,37,173,73,178,84,0,0,255,255,1,0,23,0,109,111,70,114,111,109,83,107,116,69,110,116,83,117,114,102,73,100,82,101,112,95,99,0,0,255,255,1,0,6,0,109,111,70,82,95,99,255,255,1,0,13,0,109,111,69,120,116,79,98,106,101,99,116,95,99,255,255,1,0,17,0,109,111,67,83,116,114,105,110,103,72,97,110,100,108,101,95,99,255,254,255,92,75,0,58,0,92,0,97,0,112,0,105,0,92,0,72,0,69,0,76,0,80,0,92,0,83,0,97,0,109,0,112,0,108,0,101,0,32,0,77,0,97,0,99,0,114,0,111,0,115,0,92,0,83,0,105,0,109,0,117,0,108,0,97,0,116,0,105,0,111,0,110,0,92,0,50,0,48,0,49,0,50,0,92,0,65,0,117,0,116,0,111,0,84,0,101,0,115,0,116,0,70,0,105,0,108,0,101,0,115,0,92,0,68,0,121,0,110,0,97,0,109,0,105,0,99,0,115,0,92,0,77,0,97,0,99,0,114,0,111,0,115,0,92,0,76,0,105,0,110,0,101,0,97,0,114,0,68,0,121,0,110,0,97,0,109,0,105,0,99,0,46,0,83,0,76,0,68,0,"
    selection2 = selection2 & "80,0,82,0,84,0,9,128,255,254,255,13,76,0,105,0,110,0,101,0,97,0,114,0,68,0,121,0,110,0,97,0,109,0,105,0,99,0,2,0,0,141,213,96,79,0,0,112,0,97,0,0,0,0,0,0,0,0,0,0,0,0,0,255,254,255,7,68,0,101,0,102,0,97,0,117,0,108,0,116,0,0,0,0,0,0,0,0,0,100,0,100,0,30,0,0,0,252,214,96,79,1,0,0,0,0,0,255,255,1,0,19,0,109,111,66,111,116,116,111,109,69,100,103,101,73,100,82,101,112,95,99,0,0,5,128,8,0,30,0,0,0,252,214,96,79,1,0,0,0,255,255,1,0,16,0,109,111,84,111,112,69,100,103,101,73,100,82,101,112,95,99,0,0,5,128,8,0,30,0,0,0,252,214,96,79,1,0,0,0,255,255,1,0,16,0,109,111,69,110,100,69,100,103,101,73,100,82,101,112,95,99,0,0,5,128,8,0,30,0,0,0,252,214,96,79,0,0,0,0,0,0,0,0"
    selection2 = selection2 & ",Type=1"

    'Pie edge
    selection3 = "68,20,0,0,3,0,0,0,255,254,255,0,0,0,0,0,255,255,1,0,11,0,109,111,69,100,103,101,82,101,102,95,99,1,0,0,0,0,0,0,0,5,0,0,0,6,3,0,0,0,0,0,0,125,195,148,37,173,73,178,84,125,195,148,37,173,73,178,84,0,0,255,255,1,0,23,0,109,111,70,114,111,109,83,107,116,69,110,116,83,117,114,102,73,100,82,101,112,95,99,0,0,255,255,1,0,6,0,109,111,70,82,95,99,255,255,1,0,13,0,109,111,69,120,116,79,98,106,101,99,116,95,99,255,255,1,0,17,0,109,111,67,83,116,114,105,110,103,72,97,110,100,108,101,95,99,255,254,255,92,75,0,58,0,92,0,97,0,112,0,105,0,92,0,72,0,69,0,76,0,80,0,92,0,83,0,97,0,109,0,112,0,108,0,101,0,32,0,77,0,97,0,99,0,114,0,111,0,115,0,92,0,83,0,105,0,109,0,117,0,108,0,97,0,116,0,105,0,111,0,110,0,92,0,50,0,48,0,49,0,50,0,92,0,65,0,117,0,116,0,111,0,84,0,101,0,115,0,116,0,70,0,105,0,108,0,101,0,115,0,92,0,68,0,121,0,110,0,97,0,109,0,105,0,99,0,115,0,92,0,77,0,97,0,99,0,114,0,111,0,115,0,92,0,76,0,105,0,110,0,101,0,97,0,114,0,68,0,121,0,110,0,97,0,109,0,105,0,99,0,46,0,83,0,76,0,68,0,"
    selection3 = selection3 & "80,0,82,0,84,0,9,128,255,254,255,13,76,0,105,0,110,0,101,0,97,0,114,0,68,0,121,0,110,0,97,0,109,0,105,0,99,0,2,0,0,141,213,96,79,0,0,112,0,97,0,0,0,0,0,0,0,0,0,0,0,0,0,255,254,255,7,68,0,101,0,102,0,97,0,117,0,108,0,116,0,0,0,0,0,0,0,0,0,100,0,100,0,30,0,0,0,252,214,96,79,1,0,0,0,0,0,255,255,1,0,16,0,109,111,69,110,100,69,100,103,101,73,100,82,101,112,95,99,0,0,5,128,8,0,30,0,0,0,252,214,96,79,0,0,0,0,255,255,1,0,19,0,109,111,66,111,116,116,111,109,69,100,103,101,73,100,82,101,112,95,99,0,0,5,128,8,0,30,0,0,0,252,214,96,79,1,0,0,0,255,255,1,0,16,0,109,111,84,111,112,69,100,103,101,73,100,82,101,112,95,99,0,0,5,128,8,0,30,0,0,0,252,214,96,79,1,0,0,0,0,0,0,0"
    selection3 = selection3 & ",Type=1"

    'Pie edge
    selection4 = "68,20,0,0,3,0,0,0,255,254,255,0,0,0,0,0,255,255,1,0,11,0,109,111,69,100,103,101,82,101,102,95,99,1,0,0,0,0,0,0,0,5,0,0,0,4,3,0,0,0,0,0,0,125,195,148,37,173,73,178,84,125,195,148,37,173,73,178,84,0,0,255,255,1,0,23,0,109,111,70,114,111,109,83,107,116,69,110,116,83,117,114,102,73,100,82,101,112,95,99,0,0,255,255,1,0,6,0,109,111,70,82,95,99,255,255,1,0,13,0,109,111,69,120,116,79,98,106,101,99,116,95,99,255,255,1,0,17,0,109,111,67,83,116,114,105,110,103,72,97,110,100,108,101,95,99,255,254,255,92,75,0,58,0,92,0,97,0,112,0,105,0,92,0,72,0,69,0,76,0,80,0,92,0,83,0,97,0,109,0,112,0,108,0,101,0,32,0,77,0,97,0,99,0,114,0,111,0,115,0,92,0,83,0,105,0,109,0,117,0,108,0,97,0,116,0,105,0,111,0,110,0,92,0,50,0,48,0,49,0,50,0,92,0,65,0,117,0,116,0,111,0,84,0,101,0,115,0,116,0,70,0,105,0,108,0,101,0,115,0,92,0,68,0,121,0,110,0,97,0,109,0,105,0,99,0,115,0,92,0,77,0,97,0,99,0,114,0,111,0,115,0,92,0,76,0,105,0,110,0,101,0,97,0,114,0,68,0,121,0,110,0,97,0,109,0,105,0,99,0,46,0,83,0,76,0,68,0,"
    selection4 = selection4 & "80,0,82,0,84,0,9,128,255,254,255,13,76,0,105,0,110,0,101,0,97,0,114,0,68,0,121,0,110,0,97,0,109,0,105,0,99,0,2,0,0,141,213,96,79,0,0,112,0,97,0,0,0,0,0,0,0,0,0,0,0,0,0,255,254,255,7,68,0,101,0,102,0,97,0,117,0,108,0,116,0,0,0,0,0,0,0,0,0,100,0,100,0,30,0,0,0,252,214,96,79,1,0,0,0,0,0,255,255,1,0,16,0,109,111,84,111,112,69,100,103,101,73,100,82,101,112,95,99,0,0,5,128,8,0,30,0,0,0,252,214,96,79,1,0,0,0,255,255,1,0,16,0,109,111,69,110,100,69,100,103,101,73,100,82,101,112,95,99,0,0,5,128,8,0,30,0,0,0,252,214,96,79,0,0,0,0,255,255,1,0,19,0,109,111,66,111,116,116,111,109,69,100,103,101,73,100,82,101,112,95,99,0,0,5,128,8,0,30,0,0,0,252,214,96,79,1,0,0,0,0,0,0,0"
    selection4 = selection4 & ",Type=1"

    'Axis1
    selection5 = "68,20,0,0,1,0,0,0,255,254,255,0,0,0,0,0,21,0,0,0"
    selection5 = selection5 & ",Type=1"

    'Store constants in a collection
    PIDCollection.Add selection1, "selection1"
    PIDCollection.Add selection2, "selection2"
    PIDCollection.Add selection3, "selection3"
    PIDCollection.Add selection4, "selection4"
    PIDCollection.Add selection5, "selection5"

    Set PIDInitializer = PIDCollection
End Function

Function ProcErrCode(errCode As Long) As String
    Select Case errCode
    Case 0
        ProcErrCode = "Successful."
    Case 1 To 21
        ProcErrCode = "Incorrect input conditions."
    Case 22
        ProcErrCode = "Authorization failed for this analysis type."
    Case 23
        ProcErrCode = "Mesh not found."
    Case 24
        ProcErrCode = "Analysis failed."
    Case Else
        ProcErrCode = "Unknown error condition."
    End Select
End Function



Provide feedback on this topic

SOLIDWORKS welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

 
*Email:  
Subject:   Feedback on Help Topics
Page:   Create Linear Dynamic Study Example (VBA)
*Comment:  
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:

x

We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again
x

Web Help Content Version: API Help (English only) 2013 SP05

To disable Web help from within SOLIDWORKS and use local help instead, click Help > Use SOLIDWORKS Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.