Hide Table of Contents

Get Options of Nonlinear Study (VBA)

This example shows how to get a nonlinear study's options.

'---------------------------------------------------------------
' 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. The specified file exists.
' 4. Open the Immediate window.
'
' Postconditions: Data for each nonlinear study in the
' active model is printed to the Immediate window.
'
' NOTE: Because the model is used elsewhere, do not save any
' changes when closing it.
'-------------------------------------
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swAddin As CosmosWorksLib.CwAddincallback
Dim ssApp As CosmosWorksLib.CosmosWorks
Dim ssModelDoc As CosmosWorksLib.CWModelDoc
Dim ssStudyMgr As CosmosWorksLib.CWStudyManager
Dim ssStudy As CosmosWorksLib.CWStudy
Dim ssStudyOption As Object
Dim ssNonLinearStudyOptions As CosmosWorksLib.CWNonLinearStudyOptions
Dim docName As String
Dim errors As Long
Dim warnings As Long
Dim studyCnt As Long
Dim studyName As String
Dim studyType As Long
Dim i As Long
Dim maxLoad As Double
Dim maxDisplacement As Double
Dim unit As Long
Dim maxArcSteps As Long
Dim arcLengthMultiplier As Double
Dim displacementComponent As Long
Dim selectedEntity As Object
Dim frequency As Long
Dim maximum As Long
Dim convergence As Double
Dim tolerance As Double
Dim factor As Double
Dim swEntity As Entity
Dim entityType As Long
Dim selEntityType As String
Sub main()
    Set swApp = Application.SldWorks    
    ' Open specified document, which has two nonlinear studies
    docName = "c:\Program Files\solidworks Corp\SolidWorks\Simulation\Examples\Nonlinear\nl_plate.sldprt"
    swApp.OpenDoc6 docName, swDocPART, swOpenDocOptions_Silent, "", errors, warnings    
    ' Get SolidWorks Simulation and its Study Manager object
    Set swAddin = swApp.GetAddInObject("SldWorks.Simulation")
    Set ssApp = swAddin.CosmosWorks
    Set ssModelDoc = ssApp.ActiveDoc
    Set ssStudyMgr = ssModelDoc.StudyManager    
    ' Get data for only nonlinear types of studies
    studyCnt = ssStudyMgr.StudyCount
        For i = 0 To studyCnt - 1
            Set ssStudy = ssStudyMgr.GetStudy(i)
            studyName = ssStudy.Name
                Debug.Print ""
                Debug.Print "Study name: " & studyName
            studyType = ssStudy.AnalysisType            
            If (studyType = swsAnalysisStudyTypeNonlinear) Then
            ' Get nonlinear study's data
                Set ssStudyOption = ssStudy.NonLinearStudyOptions
                Debug.Print "  Study type:  Nonlinear"
                Set ssNonLinearStudyOptions = ssStudyOption
                Debug.Print "    Control method type: " & ssNonLinearStudyOptions.ControlMethodType
                Debug.Print "    Start time: " & ssNonLinearStudyOptions.StartTime
                Debug.Print "    End time: " & ssNonLinearStudyOptions.EndTime
                Debug.Print "    Solution-time increment: " & ssNonLinearStudyOptions.TimeIncrement
                Debug.Print "    Fixed-time increment: " & ssNonLinearStudyOptions.FixedTimeIncrement
                Debug.Print "    Integration method type: " & ssNonLinearStudyOptions.IntegrationMethodType
                Debug.Print "    Results folder path: " & ssNonLinearStudyOptions.ResultFolderPath
                Debug.Print "    Save data for restarting analysis? " & ssNonLinearStudyOptions.SaveDataForRestartingAnalysis
                Debug.Print "    Solver type: " & ssNonLinearStudyOptions.SolverType
                Debug.Print "    Use large strain formulation? " & ssNonLinearStudyOptions.UseLargeStrain
                Debug.Print "    Update direction of load at every solution step with deflection? " & ssNonLinearStudyOptions.UseUpdateLoadDirection
                ssNonLinearStudyOptions.GetArcLengthCompletionOptions maxLoad, maxDisplacement, unit, maxArcSteps, arcLengthMultiplier
                Debug.Print "    Use large displacement formulation? " & ssNonLinearStudyOptions.UseLargeDisplacement
                Debug.Print "    Arc-length completion options (maximum load, maximum displacement, unit, maximum arc steps, and arc-length multiplier): " & maxLoad & ", " & maxDisplacement & ", " & unit & ", " & maxArcSteps & ", " & arcLengthMultiplier
  		selEntityType = "Nothing"
		ssNonLinearStudyOptions.GetDisplacementControlOptions2 displacementComponent, unit, selectedEntity
		If Not selectedEntity Is Nothing Then
			Set swEntity = selectedEntity
			entityType = swEntity.GetType
			Select Case entityType
				Case 3
					selEntityType = "vertex"
				Case 6
					selEntityType = "reference point"
				Case 0
					selEntityType = "Nothing"
			End Select
		End If
		Debug.Print " Displacement control options (displacement component, unit, selected entity): " & displacementComponent & ", " & unit & ", " & selEntityType
                Debug.Print "    Iterative method type: " & ssNonLinearStudyOptions.IterativeMethodType
                ssNonLinearStudyOptions.GetStepToleranceOptions frequency, maximum, convergence, tolerance, factor
                Debug.Print "    Tolerance: "
                Debug.Print "         Frequency of performing equilibrium in number of solution steps: " & frequency
                Debug.Print "         Maximum number of equilibrium iterations for any solution step: " & maximum
                Debug.Print "         Relative displacement tolerance used for equilibrium convergence: " & convergence
                Debug.Print "         Tolerance for strain increment for models with creep or plasticity: " & tolerance
                Debug.Print "         Stiffness singularity elimination factor: " & factor                Dim status As Long
                status = ssNonLinearStudyOptions.SetStepToleranceOptions(-1, 10, 0.002, 0.02, 1)
                Debug.Print "    New Tolerance: "
                Debug.Print "         Frequency of performing equilibrium in number of solution steps: " & frequency
                Debug.Print "         Maximum number of equilibrium iterations for any solution step: " & maximum
                Debug.Print "         Relative displacement tolerance used for equilibrium convergence: " & convergence
                Debug.Print "         Tolerance for strain increment for models with creep or plasticity: " & tolerance
                Debug.Print "         Stiffness singularity elimination factor: " & factor
            End If
        Next
                     
End Sub


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:   Get Options of Nonlinear Study
*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.