Hide Table of Contents

Create Linear Dynamic Study Example (VB.NET)

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 primary interop assembly as 
'    a reference (in the IDE's Project Explorer, right-click
'    the project name, select Add Reference, click the Browse tab,
'    navigate to the install_dir\api\redist\CLR2 folder, and
'    select SolidWorks.Interop.cosworks.dll).
' 3. Ensure that the specified file to open exists.
' 4. Ensure that the c:\temp folder exists.
' Postconditions:
' 1. Opens the specified file.
' 2. Creates a linear dynamic study.
' 3. Runs a harmonic analysis. 
' 4. Right-click the Stress1 or Displacement1 plot in the Results folder
'    and select Show to plot the results in color in the graphics area.
' 5. Prints the study options and results to the Immediate window.
' 6. Saves the solution step, displacement, velocity,
'    and stress result files to c:\temp.
NOTE: Because the model is used elsewhere,
' do not save any changes when closing it.
Imports SolidWorks.Interop.sldworks
Imports SolidWorks.Interop.swconst
Imports SolidWorks.Interop.cosworks
Imports System.Runtime.InteropServices
Imports System
Imports System.Diagnostics
Partial Class SolidWorksMacro
    Sub main()
        Dim Part As ModelDoc2
        Dim COSMOSWORKS As Object
        Dim CWAddinCallBack As CwAddincallback
        Dim ActDoc As CWModelDoc
        Dim StudyMngr As CWStudyManager
        Dim Study As CWStudy
        Dim ShellMgr As CWShellManager
        Dim ShellMat As CWMaterial
        Dim LBCMgr As CWLoadsAndRestraintsManager
        Dim CWBaseExcitationU As CWBaseExcitation
        Dim CWDistribMass As CWDistributedMass
        Dim CWBaseExcitationEntity As Object
        Dim CWDirectionEntity As Object
        Dim errors As Integer
        Dim warnings As Integer
        Dim errCode As Integer
        Dim nStep As Integer
        Dim pDisp5 As Object
        Dim DispArray1(0) As Object, DispArray2(0) As Object, DispArray3(0) As Object, DispArray4(1) As Object
        Dim Disp As Object, Stress As Object, Velocity As Object, Acceleration As Object
        Dim sStudyName As String
        Dim ResultOptions As CWStudyResultOptions
        Dim DampingOptions As CWDampingOptions
        Dim DampingRatios(8) As Object
        Dim i As Integer
        '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
        PIDCollection = PIDInitializer()
        'Open document
        Part = swApp.OpenDoc6("c:\Program Files\SolidWorks Corp\SolidWorks\samples\tutorial\api\lineardynamic.SLDPRT", swDocumentTypes_e.swDocPART, 1, "", errors, warnings)
        If Part Is Nothing Then ErrorMsg(SwApp, "Failed to open Linear_Dynamic_1.SLDPRT.")
        'Add-in callback
        CWAddinCallBack = SwApp.GetAddInObject("CosmosWorks.CosmosWorks")
        If CWAddinCallBack Is Nothing Then ErrorMsg(SwApp, "Failed to get CWAddinCallBack object.")
        If COSMOSWORKS Is Nothing Then ErrorMsg(SwApp, "Failed to get COSMOSWORKS object.")
        'Get active document
        ActDoc = COSMOSWORKS.ActiveDoc()
        If ActDoc Is Nothing Then ErrorMsg(SwApp, "Failed to get active document.")
        'Create a dynamic harmonic study
        StudyMngr = ActDoc.StudyManager()
        If StudyMngr Is Nothing Then ErrorMsg(SwApp, "Failed to get StudyManager object.")
        sStudyName = "Dynamic_Harmonic"
        Study = StudyMngr.CreateNewStudy3(sStudyName, swsAnalysisStudyType_e.swsAnalysisStudyTypeDynamic, swsDynamicAnalysisSubType_e.swsDynamicAnalysisSubTypeHarmonic, errCode)
        Debug.Print("Linear dynamic study with harmonic analysis")
        Debug.Print "Study configuration name is " & Study.ConfigurationName
        Debug.Print "Dynamic analysis subtype as defined in swsAnalysisStudyType_e is " & Study.DynamicAnalysisSubType
        Debug.Print("Dynamic study options...")
        Dim DynStudyOptions As CWDynamicStudyOptions
        DynStudyOptions = Study.DynamicStudyOptions
        Dim freqOption As Integer
        Dim freqValue As Double
        Dim bChecked As Long
        DynStudyOptions.GetFrequencyOption(freqOption, freqValue)
        Debug.Print("  Frequency option (0=number of frequencies, 1=upper bound): " & 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 (0=rad/sec, 1=Hz): " & DynStudyOptions.HarmonicFrequencyUnits)
        Debug.Print("  Harmonic interpolation (0=logarithmic, 1=linear): " & DynStudyOptions.HarmonicInterpolation)
        Debug.Print("  Harmonic number of points for each frequency: " & DynStudyOptions.HarmonicNoOfPoints)
        'Set study result options
        Debug.Print("Study result options...")
        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)
        'Set damping options
        DampingOptions = Study.DampingOptions
        DampingOptions.DampingType = 0 'Modal damping
        DampingRatios(0) = 1
        DampingRatios(1) = 5
        DampingRatios(2) = 3.45
        DampingRatios(3) = 6
        DampingRatios(4) = 15
        DampingRatios(5) = 15
        DampingRatios(6) = 16
        DampingRatios(7) = 25
        DampingRatios(8) = 34.5
        errCode = DampingOptions.SetDampingRatios(3, (DampingRatios))
        DampingOptions.ComputeFromMaterialDamping = 0 'Do not use the material damping ratio
        'Create VARIANT arrays
        DispArray1(0) = SelectByPID(Part, "selection1", PIDCollection)
        DispArray2(0) = SelectByPID(Part, "selection1", PIDCollection)
        DispArray3(0) = SelectByPID(Part, "selection2", PIDCollection)
        DispArray4(0) = SelectByPID(Part, "selection3", PIDCollection)
        DispArray4(1) = SelectByPID(Part, "selection4", PIDCollection)
        'Get Edge-1 by persistent ID
        CWBaseExcitationEntity = SelectByPID(Part, "selection3", PIDCollection)
        'Get Axis1 by persistent ID
        CWDirectionEntity = SelectByPID(Part, "selection5", PIDCollection)
        pDisp5 = SelectByPID(Part, "selection5", PIDCollection)
        'Add materials
        ShellMgr = Study.ShellManager
        If ShellMgr Is Nothing Then ErrorMsg(SwApp, "Failed to get ShellMgr object.")
        Dim CWFeatObj1 As CWShell
        CWFeatObj1 = ShellMgr.GetShellAt(0, errCode)
        If errCode <> 0 Then ErrorMsg(SwApp, "Failed to get shell component.")
        ShellMat = CWFeatObj1.GetDefaultMaterial
        ShellMat.MaterialUnits = 0
        Call ShellMat.SetPropertyByName("EX", 2000000000000.0#, 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 'cm
        CWFeatObj1.ShellThickness = 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.")
        CWFeatObj1 = Nothing
        'Get loads and restraints manager
        LBCMgr = Study.LoadsAndRestraintsManager
        If LBCMgr Is Nothing Then ErrorMsg(SwApp, "Failed to get LoadsAndRestraintsManager.")
        'Create normal pressure
        Dim CWFeatObj2 As CWPressure
        CWFeatObj2 = LBCMgr.AddPressure(0, (DispArray2), Nothing, errCode)
        If errCode <> 0 Then ErrorMsg(SwApp, "Failed to create normal pressure.")
        Call CWFeatObj2.PressureBeginEdit()
        Debug.Print("Normal pressure values...")
        Debug.Print("  Pressure unit in swsStrengthUnit_e units: " & CWFeatObj2.Unit)
        Debug.Print("  Pressure value: " & CWFeatObj2.Value)
        Debug.Print("  Pressure phase angle (-1 if not set): " & CWFeatObj2.PhaseAngle)
        Debug.Print("  Pressure phase unit in swsPhaseAngleUnit_e units: " & CWFeatObj2.PhaseAngleUnit)
        errCode = CWFeatObj2.PressureEndEdit
        If errCode <> 0 Then ErrorMsg(SwApp, "Failed to apply normal pressure value.")
        CWFeatObj2 = Nothing
        'Add Restraints
        Dim CWFeatObj3 As CWRestraint
        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.0#, 0.0#)
        Call CWFeatObj3.SetRotationComponentsValues(0, 0, 0, 0.0#, 0.0#, 0.0#)
        CWFeatObj3.Unit = 2
        errCode = CWFeatObj3.RestraintEndEdit
        If errCode <> 0 Then ErrorMsg(SwApp, "First RestraintEndEdit failed.")
        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.0#, 0.0#)
        Call CWFeatObj3.SetRotationComponentsValues(1, 0, 1, -0.0#, 0.0#, -0.0#)
        CWFeatObj3.Unit = 2
        errCode = CWFeatObj3.RestraintEndEdit
        If errCode <> 0 Then ErrorMsg(SwApp, "Second RestraintEndEdit failed.")
        CWFeatObj3 = Nothing
        'Add uniform base excitation
        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 (0=Disp, 1=Vel, 2=Acc): " & CWBaseExcitationU.BaseExcitationType)
        Dim bdir1 As Integer, bdir2 As Integer, bdir3 As Integer
        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 Object
        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))
        Debug.Print(" Excitation phase angle (-1 if not set): " & CWBaseExcitationU.PhaseAngle)
        Debug.Print(" Excitation phase angle unit in swsPhaseAngleUnit_e units: " & CWBaseExcitationU.PhaseAngleUnit)
        Debug.Print(" Excitation unit (dependent on excitation type): " & CWBaseExcitationU.Unit)
        'Add distributed mass
        CWDistribMass = LBCMgr.AddDistributedMass((DispArray2), 0, 1, errCode)
        Debug.Print("Total distributed mass: " & CWDistribMass.TotalMass)
        Debug.Print("  Unit in swsUnitSystem_e units: " & CWDistribMass.Units)
        'Create mesh
        Dim CWFeatObj4 As CWMesh
        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)
        'Run analysis
        Debug.Print("NOTE: Running the analysis. This can take a few minutes.")
        errCode = Study.RunAnalysis
        If errCode <> 0 Then ErrorMsg(SwApp, "Analysis failed with error code " & errCode & " - " & ProcErrCode(errCode))
        'Get results
        Dim CWFeatObj5 As CWResults
        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))
        '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))
        '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))
        '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))
        CWFeatObj5 = Nothing
    End Sub
    Sub ErrorMsg(ByVal SwApp As ObjectByVal Message As String)
        SwApp.SendMsgToUser2(Message, 0, 0)
        SwApp.RecordLine("'*** WARNING - General")
        SwApp.RecordLine("'*** " & Message)
    End Sub
    Function SelectByPID(ByVal Part As ModelDoc2, ByVal PIDName As StringByVal PIDCollection As CollectionAs Object
        Dim PID() As Byte
        Dim PIDVariant As Object
        Dim PIDString As String
        Dim i As Integer
        Dim SelObj As Object
        Dim errCode as int
        '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
        SelObj = Part.Extension.GetObjectByPersistReference3((PID), errCode)
        SelectByPID = SelObj
        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
        selection1 = "35,29,213,113,218,129,72,162,168,88,152,178,27,137,239,153,121,2,0,0,110,1,0,0,120,1,133,81,61,79,2,65,16,125,168,168,9,145,248,81,24,59,26,91,11,59,77,40,16,14,37,49,72,238,72,108,72,46,112,183,224,113,95,228,88,252,40,76,248,5,86,254,13,26,123,43,255,132,63,69,27,206,55,92,164,49,134,77,102,103,231,205,123,51,179,187,159,69,96,29,64,58,79,185,211,167,57,20,16,198,245,174,163,76,213,183,157,220,2,6,242,244,27,194,228,122,254,120,61,158,53,222,218,191,62,147,29,138,44,137,67,203,215,70,164,173,73,210,111,184,166,26,217,78,150,222,148,180,105,59,210,97,135,103,227,81,223,244,134,202,209,25,84,36,196,184,238,5,170,38,125,133,182,71,172,106,233,196,139,6,87,221,200,13,20,225,121,186,223,68,140,8,1,60,238,10,93,36,176,97,65,243,164,137,57,140,78,241,242,85,174,20,166,100,251,85,156,163,131,26,53,14,38,8,169,136,200,27,163,68,126,4,151,222,34,166,23,218,8,3,102,58,184,199,144,217,39,90,143,22,208,124,118,241,152,187,163,70,116,82,81,49,246,169,139,49,98,92,165,31,179,190,236,"
        selection1 = selection1 & "37,220,210,39,204,74,181,38,153,15,196,234,196,2,118,84,204,116,208,98,157,100,49,137,48,86,223,232,132,115,94,179,107,11,38,218,168,127,151,43,242,21,107,178,45,23,239,187,37,115,245,89,123,194,94,122,153,145,195,17,109,118,246,126,41,26,121,222,93,62,111,59,30,25,238,64,45,127,42,63,221,254,195,59,32,239,34,214,58,14,87,82,165,164,17,185,255,242,100,140,108,253,0,133,117,156,59,0,0,0,0,0,0,0,0"
        selection1 = selection1 & ",Type=1"
        selection2 = "35,29,213,113,218,129,72,162,168,88,152,178,27,137,239,153,121,2,0,0,109,1,0,0,120,1,141,81,187,78,2,81,16,61,168,168,9,145,248,40,140,29,141,173,133,157,38,20,200,67,73,12,146,93,18,27,146,13,236,94,112,217,23,89,46,62,10,19,190,192,202,223,160,177,183,242,39,252,20,109,88,207,176,96,108,140,22,247,158,157,51,231,204,204,222,121,207,3,171,0,146,89,194,155,152,100,144,67,16,85,157,190,50,84,207,178,51,115,26,200,18,215,86,210,224,241,237,249,112,90,127,105,45,49,181,237,211,86,139,163,192,244,116,53,212,230,56,238,213,29,67,13,45,59,77,175,75,218,176,108,233,176,37,29,238,245,85,119,160,108,157,82,121,82,140,107,174,175,42,210,87,100,59,228,202,166,142,221,176,127,209,9,29,95,145,158,37,187,13,68,8,225,195,229,173,208,65,12,11,38,52,191,52,57,155,209,49,158,62,138,165,220,132,106,175,140,83,180,81,161,199,198,24,1,29,33,117,35,20,168,15,225,16,77,114,122,238,13,209,103,166,141,91,12,152,125,224,233,242,248,60,30,187,184,204,221,208,35,62,169,168,24,123,244,69,24,50,46,"
        selection2 = selection2 & "19,71,172,47,119,1,215,196,152,89,169,214,160,242,142,92,141,156,207,142,138,153,54,154,172,19,207,39,17,197,223,127,116,196,57,47,217,181,9,3,45,212,62,139,37,89,198,98,35,233,94,100,139,27,50,87,143,181,199,236,165,23,124,10,7,132,233,201,235,121,234,145,7,222,227,3,159,69,90,71,129,236,251,123,93,217,201,38,126,138,69,186,77,105,43,26,254,75,87,13,157,95,117,203,137,190,0,97,76,156,64,0,0,0,0,0,0,0,0"
        selection2 = selection2 & ",Type=1"
        selection3 = "35,29,213,113,218,129,72,162,168,88,152,178,27,137,239,153,121,2,0,0,112,1,0,0,120,1,133,81,187,78,2,81,16,61,168,168,9,145,248,40,140,29,141,173,133,157,38,20,200,67,73,12,146,93,18,27,146,13,236,94,112,217,23,89,46,62,10,19,190,192,202,223,160,177,183,242,39,252,20,109,88,207,176,96,108,136,197,189,103,231,204,57,51,179,119,62,243,192,58,128,100,150,240,38,38,25,228,16,68,85,167,175,12,213,179,236,204,156,6,178,196,141,181,52,120,254,120,61,158,214,223,90,75,76,109,135,180,213,226,40,48,61,93,13,181,57,142,123,117,199,80,67,203,78,211,155,146,54,44,91,58,236,72,135,71,125,211,29,40,91,167,84,158,20,227,154,235,171,138,244,21,217,30,185,178,169,99,55,236,95,117,66,199,87,164,103,201,126,3,17,66,248,112,121,43,116,16,195,130,9,205,47,77,206,102,116,138,151,175,98,41,55,161,218,43,227,28,109,84,232,177,49,70,64,71,72,221,8,5,234,67,56,68,147,156,158,123,67,244,153,105,227,30,3,102,159,120,186,60,62,143,199,46,46,115,119,244,136,79,42,42,198,30,125,17,134,140,203,196,17,"
        selection3 = selection3 & "235,203,93,192,45,49,102,86,170,53,168,124,32,87,35,231,179,163,98,166,141,38,235,196,243,73,68,241,255,31,157,112,206,107,118,109,194,64,11,181,239,98,73,150,177,216,72,186,23,217,226,150,204,213,99,237,49,123,233,5,159,194,17,97,122,246,126,153,122,228,129,119,249,192,173,104,40,203,254,221,85,118,178,141,191,202,165,174,26,58,43,117,82,95,116,7,172,119,17,105,29,5,43,165,203,129,127,0,55,20,156,64,0,0,0,0,0,0,0,0"
        selection3 = selection3 & ",Type=1"
        selection4 = "35,29,213,113,218,129,72,162,168,88,152,178,27,137,239,153,121,2,0,0,110,1,0,0,120,1,133,81,187,78,2,81,20,28,52,162,9,145,248,40,140,29,141,173,133,157,38,20,8,172,146,24,36,187,36,54,36,27,216,189,224,178,47,178,92,124,20,38,124,129,149,191,65,99,111,229,79,248,41,218,176,206,97,193,78,45,238,157,61,115,102,230,92,56,31,69,96,29,64,58,79,121,19,211,28,10,8,227,186,59,80,166,234,219,78,110,65,3,27,196,252,90,86,60,189,191,28,205,26,175,237,21,102,182,3,218,140,36,14,45,95,215,35,109,77,146,126,195,53,213,200,118,178,118,94,218,166,237,200,132,109,153,240,160,175,123,67,229,232,140,42,146,98,109,120,129,170,201,92,145,237,146,171,90,58,241,162,193,101,55,114,3,69,122,158,238,53,17,35,66,0,143,183,66,23,9,108,88,208,252,210,228,28,86,39,120,254,44,87,10,83,170,253,42,206,208,65,141,30,7,19,132,116,68,212,141,81,162,62,130,75,180,200,233,133,55,194,128,157,14,238,48,100,247,145,167,199,19,240,248,156,226,177,119,75,143,248,36,81,177,246,233,139,49,98,93,37,142,153,47,119"
        selection4 = selection4 & ",9,55,196,132,93,73,107,82,121,79,206,32,23,112,162,98,167,131,22,115,146,197,75,68,241,255,47,58,230,59,175,56,181,5,19,109,24,95,229,138,44,99,185,145,108,47,178,197,77,121,87,159,217,19,206,210,75,62,131,67,194,236,244,237,34,243,200,31,188,35,123,136,92,89,246,207,174,54,166,91,88,41,197,39,186,125,234,206,99,173,227,240,87,169,132,174,34,219,241,232,79,157,196,126,3,73,147,156,66,0,0,0,0,0,0,0,0"
        selection4 = selection4 & ",Type=1"
        selection5 = "35,29,213,113,218,129,72,162,168,88,152,178,27,137,239,153,20,0,0,0,25,0,0,0,120,1,187,193,199,192,192,200,192,192,240,255,223,127,32,201,192,32,5,196,0,51,74,3,254,0,0,0,0,0,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")
        PIDInitializer = PIDCollection
    End Function
    Function ProcErrCode(ByVal errCode As IntegerAs 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
    Public swApp As SldWorks
End Class

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

Subject:   Feedback on Help Topics
Page:   Create Linear Dynamic Study Example (VB.NET)
*   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:


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

Web Help Content Version: API Help (English only) 2014 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.