Welcome
Expand Getting StartedGetting Started
Expand SOLIDWORKS API HelpSOLIDWORKS API Help
Expand SOLIDWORKS Electrical API HelpSOLIDWORKS Electrical API Help
Expand SOLIDWORKS PDM Professional API HelpSOLIDWORKS PDM Professional API Help
Expand PDM Pro API Web ServicePDM Pro API Web Service
Expand FeatureWorks API HelpFeatureWorks API Help
Expand SOLIDWORKS Costing API HelpSOLIDWORKS Costing API Help
Expand SOLIDWORKS Document Manager API HelpSOLIDWORKS Document Manager API Help
Expand SOLIDWORKS Inspection API HelpSOLIDWORKS Inspection API Help
Expand SOLIDWORKS Routing API HelpSOLIDWORKS Routing API Help
Collapse SOLIDWORKS Simulation API HelpSOLIDWORKS Simulation API Help
Welcome
Functional Categories
Release Notes
Getting Started
Collapse SolidWorks.Interop.cosworks NamespaceSolidWorks.Interop.cosworks Namespace
Overview
Collapse InterfacesInterfaces
Expand ICosmosWorksICosmosWorks
Expand ICWBaseExcitationICWBaseExcitation
Expand ICWBeamBodyICWBeamBody
Expand ICWBeamManagerICWBeamManager
Expand ICWBearingConnectorICWBearingConnector
Expand ICWBearingLoadICWBearingLoad
Expand ICWBoltConnectorICWBoltConnector
Expand ICWBucklingStudyOptionsICWBucklingStudyOptions
Expand ICWCableICWCable
Expand ICWCentriFugalForceICWCentriFugalForce
Expand ICWCompositeShellOptionsICWCompositeShellOptions
Expand ICWContactComponentICWContactComponent
Expand ICWContactManagerICWContactManager
Expand ICWContactSetICWContactSet
Expand ICWConvectionICWConvection
Expand ICWDampingOptionsICWDampingOptions
Expand ICWDistributedMassICWDistributedMass
Expand ICWDropTestResultOptionsICWDropTestResultOptions
Expand ICWDropTestSetupICWDropTestSetup
Expand ICWDropTestStudyOptionsICWDropTestStudyOptions
Expand ICWDynamicInitialConditionICWDynamicInitialCondition
Expand ICWDynamicStudyOptionsICWDynamicStudyOptions
Expand ICWEdgeWeldConnectorICWEdgeWeldConnector
Expand ICWElasticConnectorICWElasticConnector
Expand ICWFatigueEventICWFatigueEvent
Expand ICWFatigueStudyOptionsICWFatigueStudyOptions
Expand ICWForceICWForce
Expand ICWFrequencyStudyOptionsICWFrequencyStudyOptions
Expand ICWGeneralSpringConnectorICWGeneralSpringConnector
Expand ICWGravityICWGravity
Expand ICWHeatFluxICWHeatFlux
Expand ICWHeatPowerICWHeatPower
Expand ICWJointsICWJoints
Expand ICWLinkageRodICWLinkageRod
Expand ICWLinkConnectorICWLinkConnector
Expand ICWLoadCaseManagerICWLoadCaseManager
Expand ICWLoadsAndRestraintsICWLoadsAndRestraints
Expand ICWLoadsAndRestraintsManagerICWLoadsAndRestraintsManager
Expand ICWMassPropertiesManagerICWMassPropertiesManager
Expand ICWMaterialICWMaterial
Expand ICWMeshICWMesh
Expand ICWMeshControlICWMeshControl
Expand ICWModelDocICWModelDoc
Expand ICWMultipleComponentContactsEditManagerICWMultipleComponentContactsEditManager
Expand ICWMultipleContactSetsEditManagerICWMultipleContactSetsEditManager
Expand ICWNonLinearStudyOptionsICWNonLinearStudyOptions
Expand ICWPinConnectorICWPinConnector
Expand ICWPlotICWPlot
Expand ICWPressureICWPressure
Expand ICWRadiationICWRadiation
Expand ICWRemoteLoadICWRemoteLoad
Expand ICWRestraintICWRestraint
Expand ICWResultsICWResults
Expand ICWResultsProbeManagerICWResultsProbeManager
Expand ICWRigidConnectorICWRigidConnector
Expand ICWRunSpecStudiesRunMeshOptionsICWRunSpecStudiesRunMeshOptions
Expand ICWRunStudiesResultsICWRunStudiesResults
Expand ICWShellICWShell
Expand ICWShellManagerICWShellManager
Expand ICWSolidBodyICWSolidBody
Expand ICWSolidComponentICWSolidComponent
Expand ICWSolidManagerICWSolidManager
Expand ICWSpotWeldConnectorICWSpotWeldConnector
Expand ICWSpringConnectorICWSpringConnector
Expand ICWStaticStudyOptionsICWStaticStudyOptions
Expand ICWStudyICWStudy
Expand ICWStudyManagerICWStudyManager
Expand ICWStudyResultOptionsICWStudyResultOptions
Expand ICWTemperatureICWTemperature
Expand ICWThermalStudyOptionsICWThermalStudyOptions
Expand ICWTopologyDemoldControlICWTopologyDemoldControl
Expand ICWTopologyDisplacementConstraintICWTopologyDisplacementConstraint
Expand ICWTopologyFactorOfSafetyConstraintICWTopologyFactorOfSafetyConstraint
Expand ICWTopologyFrequencyConstraintICWTopologyFrequencyConstraint
Expand ICWTopologyMassConstraintICWTopologyMassConstraint
Expand ICWTopologyMinimizeMaximumDisplacementGoalICWTopologyMinimizeMaximumDisplacementGoal
Expand ICWTopologyPreservedRegionControlICWTopologyPreservedRegionControl
Expand ICWTopologyStressConstraintICWTopologyStressConstraint
Expand ICWTopologyStudyManagerICWTopologyStudyManager
Expand ICWTopologyStudyOptionsICWTopologyStudyOptions
Expand ICWTopologySymmetryControlICWTopologySymmetryControl
Expand ICWTopologyThicknessControlICWTopologyThicknessControl
Expand ICWTrendTrackerICWTrendTracker
Expand SOLIDWORKS Sustainability API HelpSOLIDWORKS Sustainability API Help
Expand SOLIDWORKS Toolbox API HelpSOLIDWORKS Toolbox API Help
Expand SOLIDWORKS Utilities API HelpSOLIDWORKS Utilities API Help
Expand SOLIDWORKS Visualize API HelpSOLIDWORKS Visualize API Help
Expand eDrawings API HelpeDrawings API Help
Expand DraftSight API HelpDraftSight API Help
Expand Lisp Programming BasicsLisp Programming Basics
Expand Lisp Functions OverviewLisp Functions Overview
Expand Lisp Functions ReferenceLisp Functions Reference
Expand Visual Lisp Compatible FunctionsVisual Lisp Compatible Functions
Hide Table of Contents
ICWCable Interface

Allows access to a cable connector.

.NET Syntax

Visual Basic (Declaration) 
Public Interface ICWCable 
Visual Basic (Usage) 
Dim instance As ICWCable
C# 
public interface ICWCable 
C++/CLI 
public interface class ICWCable 

Example

'VBA

'This example demonstrates how to create a cable connector.

 '===========================================================

'Preconditions:

'1. Open an assembly with three parts that you will connect with two cables.

'2. Create a static study that has requisite loads and fixtures and uses the Intel Direct Sparse Solver.

'3. Modify SelectByRay parameters in the code below to select edges/faces on each set of two parts to connect.

'4. Ensure the material library exists.

'5. Open an Immediate window.

'

'Postconditions:

'1. Gets the study.

'2. Creates two cable connectors (both with diameter 0.02 m, safe axial strength 2400 N/m^2, and Alloy Steel)

'   between the two sets of parts selected in step 3 of the preconditions.

'3. Meshes the study.

'4. Runs the analysis.

'5. Gets the results.

'6. Gets connector results/force.

'7. Compares connector forces.
'==============================================================

Option Explicit

Sub main()

    Dim SwApp As SldWorks.SldWorks

    Dim Part As SldWorks.ModelDoc2

    Dim COSMOSWORKSObj As CosmosWorksLib.COSMOSWORKS

    Dim CWAddinCallBackObj As CosmosWorksLib.CWAddinCallBack

    Dim StudyObj As CosmosWorksLib.CWStudy

    Dim CWCable As CosmostWorksLib.CWCable

    Dim CWCable2 As CosmostWorksLib.CWCable

    Dim CWMesh As CosmosWorksLib.CWMesh

    Dim CWResult As CosmosWorksLib.CWResults

    Dim boolstatus As Boolean

    Dim errCode As Long

    Dim longstatus As Long, longwarnings As Long

   

    Dim myModelView As SldWorks.ModelView

    Dim ActiveDocObj As CosmosWorksLib.CWModelDoc

    Dim StudyManagerObj As CosmosWorksLib.CWStudyManager

    Dim LoadsAndRestraintsManagerObj As CosmosWorksLib.CWLoadsAndRestraintsManager

  

    Dim el As Double, tl As Double, Tol1 As Double, Connector_Force1 As Double, Connector_Force2 As Double

    Dim strMaterialLib As String

   

    Set SwApp = Application.SldWorks

    Set Part = SwApp.ActiveDoc

    'Addin Callback

    Set CWAddinCallBackObj = SwApp.GetAddInObject("CosmosWorks.CosmosWorks")

    If CWAddinCallBackObj Is Nothing Then ErrorMsg2 SwApp, "CWAddinCallBackObj object not found", True

    Set COSMOSWORKSObj = CWAddinCallBackObj.COSMOSWORKS

    If COSMOSWORKSObj Is Nothing Then ErrorMsg2 SwApp, "COSMOSWORKSObj object not found", True

    'Set material Library

    strMaterialLib = "e:\Program Files\SOLIDWORKS Corp\SOLIDWORKS\lang\english\sldmaterials\solidworks materials.sldmat"

   

    Set myModelView = Part.ActiveView

    myModelView.FrameLeft = 0

    myModelView.FrameTop = 0

    Set myModelView = Part.ActiveView

    myModelView.FrameState = swWindowState_e.swWindowMaximized

    Set myModelView = Part.ActiveView

    myModelView.FrameState = swWindowState_e.swWindowMaximized

    'Get active document

    Set ActiveDocObj = COSMOSWORKSObj.ActiveDoc()

    If ActiveDocObj Is Nothing Then ErrorMsg2 SwApp, "No Active Document", True

       

    'Activate the study

    Set StudyManagerObj = ActiveDocObj.StudyManager()

    If StudyManagerObj Is Nothing Then ErrorMsg2 SwApp, "StudyManagerObj object not there", True

    StudyManagerObj.ActiveStudy = 0

    Set StudyObj = StudyManagerObj.GetStudy(0)

    If StudyObj Is Nothing Then ErrorMsg2 SwApp, "Study not created", True

 

    ' Select the first pair of items to connect by cable; select faces only for solid bodies; select edges for shells

    boolstatus = Part.Extension.SelectByRay(0.921920271769864, 1.16713776277859, 1.33177419666754, -0.34176252876859, -0.236529471640091, 0.909534047177652, 8.42662241140337E-04, 2, True, 0, 0)

    boolstatus = Part.Extension.SelectByRay(0.645679844298542, 0.837284425334389, 1.33287586529872, -0.34176252876859, -0.236529471640091, 0.909534047177652, 6.82790794058472E-04, 2, True, 0, 0)

    ' Redraw

    Part.GraphicsRedraw2

       

    Dim StudyObj As Object

    Set StudyObj = StudyManagerObj.GetStudy(0)

    Set LoadsAndRestraintsManagerObj = StudyObj.LoadsAndRestraintsManager()

    Dim DispatchObj1 As Object

    Set DispatchObj1 = Part.SelectionManager.GetSelectedObject6(1, -1)

    Dim DispatchObj2 As Object

    Set DispatchObj2 = Part.SelectionManager.GetSelectedObject6(2, -1)

    Dim DispArray As Variant

    DispArray = Array(DispatchObj1)

    Dim DispArray2 As Variant

    DispArray2 = Array(DispatchObj2)

    Set CWCable = LoadsAndRestraintsManagerObj.AddCable((DispArray), (DispArray2), 0, errCode)

    If errCode <> 0 Then ErrorMsg2 SwApp, "Cable-2 creation failed", True

   

    Set CWCable = LoadsAndRestraintsManagerObj.GetCable("Cable-2", errCode)

    CWCable.BeginEdit

    errCode = CWCable.SetFlipOffsetDirAtEnd1(0)

    If errCode <> 0 Then ErrorMsg2 SwApp, "Cable-2 SetFlipOffsetDirAtEnd1 failed", True

    errCode = CWCable.SetOffsetAtEnd1(0.01)

    If errCode <> 0 Then ErrorMsg2 SwApp, "Cable-2 SetOffsetAtEnd1 failed", True

    errCode = CWCable.SetFlipOffsetDirAtEnd2(0)

    If errCode <> 0 Then ErrorMsg2 SwApp, "Cable-2 SetFlipOffsetDirAtEnd2 failed", True

    errCode = CWCable.SetOffsetAtEnd2(0.01)

    If errCode <> 0 Then ErrorMsg2 SwApp, "Cable-2 SetOffsetAtEnd2 failed", True

    errCode = CWCable.SetCableParams(0.02, 2400, 0#)

    If errCode <> 0 Then ErrorMsg2 SwApp, "Cable-2 SetCableParams failed", True

    CWCable.MaterialSource = 1

    CWCable.SetLibraryMaterial strMaterialLib, "Alloy Steel"

    errCode = CWCable.EndEdit()

    If errCode <> 0 Then ErrorMsg2 SwApp, "Cable-2 EndEdit failed", True

 

    ' Select the second pair of items to connect by cable; select faces only for solid bodies; select edges for shells

    boolstatus = Part.Extension.SelectByRay(0.373018956619831, 1.17464121526402, 1.33263008238066, -0.34176252876859, -0.236529471640091, 0.909534047177652, 9.80012553162479E-04, 2, True, 0, 0)

    boolstatus = Part.Extension.SelectByRay(0.644518640365447, 0.841241138500749, 1.33311291616565, -0.34176252876859, -0.236529471640091, 0.909534047177652, 1.69346169186476E-03, 2, True, 0, 0)

    Part.GraphicsRedraw2

       

    Set StudyObj = StudyManagerObj.GetStudy(0)

    Set LoadsAndRestraintsManagerObj = StudyObj.LoadsAndRestraintsManager()

    Set DispatchObj1 = Part.SelectionManager.GetSelectedObject6(1, -1)

    Set DispatchObj2 = Part.SelectionManager.GetSelectedObject6(2, -1)

    DispArray = Array(DispatchObj1)

    DispArray2 = Array(DispatchObj2)

    Set CWCable2 = LoadsAndRestraintsManagerObj.AddCable((DispArray), (DispArray2), 0, errCode)

    If errCode <> 0 Then ErrorMsg2 SwApp, "Cable-3 creation failed", True

   

    Set CWCable2 = LoadsAndRestraintsManagerObj.GetCable("Cable-3", errCode)

    CWCable2.BeginEdit

    errCode = CWCable2.SetFlipOffsetDirAtEnd1(0)

    If errCode <> 0 Then ErrorMsg2 SwApp, "Cable-3 SetFlipOffsetDirAtEnd1 failed", True

    errCode = CWCable2.SetOffsetAtEnd1(0.01)

    If errCode <> 0 Then ErrorMsg2 SwApp, "Cable-3 SetOffsetAtEnd1 failed", True

    errCode = CWCable2.SetFlipOffsetDirAtEnd2(0)

    If errCode <> 0 Then ErrorMsg2 SwApp, "Cable-3 SetFlipOffsetDirAtEnd2 failed", True

    errCode = CWCable2.SetOffsetAtEnd2(0.01)

    If errCode <> 0 Then ErrorMsg2 SwApp, "Cable-3 SetOffsetAtEnd2 failed", True

    errCode = CWCable2.SetCableParams(0.02, 2400, 0#)

    If errCode <> 0 Then ErrorMsg2 SwApp, "Cable-3 SetCableParams failed", True

    CWCable2.MaterialSource = 1

    CWCable2.SetLibraryMaterial strMaterialLib, "Alloy Steel"

  

    errCode = CWCable2.EndEdit()

    If errCode <> 0 Then ErrorMsg2 SwApp, "Cable-3 EndEdit failed", True

   

    Part.ClearSelection2 True

   

    'Mesh

    Set CWMesh = StudyObj.Mesh

    If CWMesh Is Nothing Then ErrorMsg2 SwApp, "No Mesh Object", False

    CWMesh.Quality = 1

    CWMesh.MesherType = 0  '2 'BCB

    Call CWMesh.GetDefaultElementSizeAndTolerance(0, el, tl)

    errCode = StudyObj.CreateMesh(0, el, tl)

    If errCode <> 0 Then ErrorMsg2 SwApp, "Mesh failed", True

  

    'Run Analysis

    errCode = StudyObj.RunAnalysis

    If errCode <> 0 Then ErrorMsg2 SwApp, "Analysis failed", True

       

    Part.GraphicsRedraw2

    'Get results

    Set CWResult = StudyObj.Results

    If CWResult Is Nothing Then ErrorMsg2 SwApp, "No Result Object", False

     

    'Get connector results/Force

    Dim Force1, Force2 As Variant

    Force1 = CWResult.GetConnectorForces2(1, "Cable-2", 0, errCode)

    Force2 = CWResult.GetConnectorForces2(1, "Cable-3", 0, errCode)

    Connector_Force1 = 1380  'Expected axial force (comp = 7)

    Connector_Force2 = 1390  'Expected axial force (comp = 7)

    Tol1 = 0.1

    Dim i As Integer

    For i = 0 To 10

       Debug.Print i & " : " & Force1(i)

       SwApp.RecordLine "'******** Cable-2 Force " & i & " : " & Force1(i) & " ********"

    Next i

   

    If errCode <> 0 Then ErrorMsg2 SwApp, "No connector force", True

   

    If ((Force1(7)) < 0.95 * Connector_Force1) Or ((Force1(7)) > 1.05 * Connector_Force1) Then

    ErrorMsg2 SwApp, "O/p Force % error = " & (((Force1(7) - Connector_Force1) / Connector_Force1) * 100), False

    End If

   

    For i = 0 To 10

       Debug.Print i & " : " & Force2(i)

       SwApp.RecordLine "'******** Cable-3 Force " & i & " : " & Force2(i) & " ********"

    Next i

   

    If errCode <> 0 Then ErrorMsg2 SwApp, "No connector force", True

   

    If ((Force2(7)) < 0.95 * Connector_Force2) Or ((Force2(7)) > 1.05 * Connector_Force2) Then

    ErrorMsg2 SwApp, "O/p Force % error = " & (((Force2(7) - Connector_Force2) / Connector_Force2) * 100), False

    End If

  

End Sub

 

Function ErrorMsg2(SwApp As Object, Message As String, EndTest As Boolean)

    SwApp.SendMsgToUser2 Message, 0, 0

    SwApp.RecordLine "'*** WARNING - General"

    SwApp.RecordLine "'*** " & Message

    SwApp.RecordLine ""

End Function

 

Accessors

See Also



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:   ICWCable Interface
*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) 2026 PR1

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.