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 type library as a reference
'    (in the IDE, click Tools > References > SolidWorks
'    Simulation version type library
).
' 3. Create a model that consists of the following features:
'    * Surface-Revolve1 (sketch a line segment and surface-revolve it 90 degrees about an axis)
'    * Axis1
'           
' 4. Use install_dir\api\pidcollector.exe to generate PIDs for the entity selections in PidInitializer().
'
' Postconditions:
' 1. A linear dynamic study is created.
' 2. An harmonic analysis is run.
' 3. 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-)
' 4. 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.
' 5. 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
' 6. 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.
'----------------------------------------------------------------------------

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 longstatus As Long
        Dim longwarnings As Long
        Dim errCode As Long
        Dim nStep As Long
        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 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
        PIDCollection = PIDInitializer()

        
'Addin callback
        CWAddinCallBack = SwApp.GetAddInObject("SldWorks.Simulation")
        
If CWAddinCallBack Is Nothing Then ErrorMsg(SwApp, "Failed to get CWAddinCallBack object.")
        COSMOSWORKS = CWAddinCallBack.COSMOSWORKS
        
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, swsDynamicStudySubOption_e.swsDynamicHarmonic, errCode)

        Debug.Print(
"Linear dynamic study with harmonic analysis")
        Debug.Print(
"")
        Debug.Print(
"Dynamic study options...")
        
Dim DynStudyOptions As CWDynamicStudyOptions
        DynStudyOptions = Study.DynamicStudyOptions
        
Dim freqOption As Long
        Dim freqValue As Double
        Dim bChecked As Long
        DynStudyOptions.GetFrequencyOption(freqOption, freqValue)
        Debug.Print(
"  Frequency option (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 (swsFrequencyUnit_e): " & DynStudyOptions.HarmonicFrequencyUnits)
        Debug.Print(
"  Harmonic interpolation (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...")
        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
        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 ' 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.")
        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()
        CWFeatObj2.Unit = 0
        CWFeatObj2.Value = 4000000.0#
        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 (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 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))
        
Next
        Debug.Print("Phase angle: " & CWBaseExcitationU.PhaseAngle)
        Debug.Print(
"Phase angle unit (swsPhaseAngleUnit_e): " & CWBaseExcitationU.PhaseAngleUnit)
        Debug.Print(
"Units (depends on type of base excitation): " & CWBaseExcitationU.Unit)
        Debug.Print(
"")

        
'Add distributed mass
        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 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)
        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 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))
        
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

        CWFeatObj5 = Nothing

    End Sub

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

    Function SelectByPID(ByVal Part As ModelDoc2, ByVal PIDName As String, ByVal PIDCollection As Collection) As Object
        Dim PID() As Byte
        Dim PIDVariant As Object
        Dim PIDString As String
        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
        SelObj = Part.Extension.GetObjectByPersistReference((PID))
        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

       'Replace the PID strings below with strings generated by pidcollector.exe

       '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")

        PIDInitializer = PIDCollection
    
End Function

    Function ProcErrCode(ByVal 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

  
    
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

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