Hide Table of Contents

Set Composite Shell Options Example (VB.NET)

This example shows how to set composite shell options.

'----------------------------------------------------------------------------
' Preconditions:
' 1. Add the SOLIDWORKS Simulation as an add-in
'    (in SOLIDWORKS, select Tools > Add-ins > SOLIDWORKS Simulation
'    and click OK).
' 2. Add the SOLIDWORKS Simulation primary interop assembly as a reference 
'    (in the IDE's Project Explorer, right-click
'    the project name, click Add Reference, click the Browse tab,
'    navigate to install_dir\api\redist\CLR2
'    click SolidWorks.Interop.cosworks.dll, and click OK).
' 3. Ensure that the specified material library exists.
' 4. Ensure that the specified model document exists.
'
' Postconditions:
' 1. Opens the model.
' 2. Activates Ready - 8 plies.
' 3. Sets composite shell options.
' 4. Meshes the model.
' 5. Analyzes the study.
'
' NOTE: Because the model is used elsewhere, do not save changes.
'----------------------------------------------------------------------------
Imports SolidWorks.Interop.sldworks
Imports SolidWorks.Interop.swconst
Imports SolidWorks.Interop.cosworks
Imports System.Runtime.InteropServices
Imports System
 
Partial Class SolidWorksMacro
 
   
    Dim COSMOSWORKS As CosmosWorks
    Dim COSMOSObject As CwAddincallback
    Dim ActDoc As CWModelDoc
    Dim StudyMngr As CWStudyManager
    Dim Study As CWStudy
    Dim Shell As CWShell
    Dim Mesh As CWMesh
    Dim StaticOptions As CWStaticStudyOptions
    Dim Part As ModelDoc2
    Dim ShellMgr As CWShellManager
    Dim CWShellOptions As CWCompositeShellOptions
    Dim CWMat As CWMaterial
    Dim m As Integer
    Dim errCode As Integer
    Dim longstatus As Integer, longwarnings As Integer
    Dim bApp As Boolean
    Dim j As Integer
 
    Const MeshEleSize As Double = 1.4769
    Const MeshTol As Double = 0.073847
 
 
    Sub main()
 
        COSMOSObject = swApp.GetAddInObject("CosmosWorks.CosmosWorks")
        If COSMOSObject Is Nothing Then ErrorMsg(swApp, "Simulation add-in not loaded")
        COSMOSWORKS = COSMOSObject.COSMOSWORKS
        If COSMOSWORKS Is Nothing Then ErrorMsg(swApp, "No COSMOSWORKS object")
 
        Part = swApp.OpenDoc6("C:\Program Files\SOLIDWORKS Corp\SOLIDWORKS\Simulation\Examples\Composites\tjoint.SLDPRT", swDocumentTypes_e.swDocPART, 2, "", longstatus, longwarnings)
        If Part Is Nothing Then ErrorMsg(swApp, "Failed to open tjoint.SLDPRT")
 
        ActDoc = COSMOSWORKS.ActiveDoc()
        If ActDoc Is Nothing Then ErrorMsg(swApp, "No active document")
 
        StudyMngr = ActDoc.StudyManager()
        If StudyMngr Is Nothing Then ErrorMsg(swApp, "No study manager")
        StudyMngr.ActiveStudy = 1
        Study = StudyMngr.GetStudy(1)
 
        ShellMgr = Study.ShellManager
        If ShellMgr Is Nothing Then ErrorMsg(swApp, "No shell manager")
 
        Shell = ShellMgr.GetShellAt(0, errCode)
        If errCode <> 0 Then ErrorMsg(swApp, "No shell")
 
        Shell.ShellBeginEdit()
        bApp = Shell.SetLibraryMaterial("C:\Program Files\SOLIDWORKS Corp\SOLIDWORKS\lang\english\sldmaterials\solidworks materials.sldmat""Alloy Steel")
        Shell.Formulation = 2
 
        CWShellOptions = Shell.CompositeOptions
        If CWShellOptions Is Nothing Then ErrorMsg(swApp, "No composite shell options")
 
        CWShellOptions.Symmetric = 0
        CWShellOptions.RotateZeroDegreeReference = 0
        CWShellOptions.MappingType = 0
        CWShellOptions.Symmetric = 0
        CWShellOptions.Sandwich = 0
        CWShellOptions.PlyRelativeAngle = 0
        CWShellOptions.LengthUnit = 4
        CWShellOptions.AllPliesSameMaterial = 1
 
        m = CWShellOptions.GetTotalPlies()
        CWMat = Shell.GetShellMaterial
        For j = 0 To m - 1
            errCode = CWShellOptions.SetPlyParameters(j + 1, 0.1 * (j + 1), 0.05 * j, CWMat)
        Next j
 
        Shell.ShellEndEdit()
 
        'Mesh
        Mesh = Study.Mesh
        Mesh.MesherType = 0
        Mesh.Quality = 0
        errCode = Study.CreateMesh(0, MeshEleSize, MeshTol)
 
        StaticOptions = Study.StaticStudyOptions
        StaticOptions.SolverType = 2
 
        'Run analysis
        errCode = Study.RunAnalysis
 
    End Sub
 
    Sub ErrorMsg(ByVal SwApp As SldWorks, ByVal Message As String)
        SwApp.SendMsgToUser2(Message, 0, 0)
        SwApp.RecordLine("'*** WARNING - General")
        SwApp.RecordLine("'*** " & Message)
        SwApp.RecordLine("")
    End Sub
 
    ''' <summary>
    ''' The SldWorks swApp variable is pre-assigned for you.
    ''' </summary>
    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:   Set Composite Shell Options 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) 2015 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.