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 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 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 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
ICWBearingConnector Interface

Allows access to a bearing connector.

.NET Syntax

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

Example

'VBA

'This example demonstrates how to create a bearing connector for a shaft and its housing. Contact API Support to obtain the assembly and components that work with this example.

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

'Preconditions:

'1. Obtain the relevant assembly and components from API Support and open the assembly in SOLIDWORKS.

'2. Load the SOLIDWORKS Simulation add-in.

'3. Add the SOLIDWORKS Simulation type library as a reference.

'4. (Optional) Uncomment code to compare connector forces.

'5. Open an Immediate window.

'

'Postconditions:

'1. Activates and gets the Static 5_Rigid study.

'2. Creates a bearing connector.

'3. Meshes the model.

'4. Analyzes the study.

'5. Gets the analysis results.

'6. Gets the connector results and forces.

'7. (Optional) Compares connector forces.

'8. Inspect the Immediate window and the Simulation study tree.

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

Dim SwApp As SldWorks.SldWorks

Dim Part As SldWorks.ModelDoc2

Dim swAssembly As SldWorks.AssemblyDoc

Dim myModelView As SldWorks.ModelView

Dim boolstatus As Boolean

Dim longstatus As Long, longwarnings As Long

Option Explicit

Sub main()

 

    Dim COSMOSWORKSObj As CosmosWorksLib.COSMOSWORKS

    Dim CWAddinCallBackObj As CosmosWorksLib.CWAddinCallBack

    Dim ActiveDocObj As CosmosWorksLib.CWModelDoc

    Dim StudyManagerObj As CosmosWorksLib.CWStudyManager

    Dim CWMesh As CosmosWorksLib.CWMesh

    Dim CWResult As CosmosWorksLib.CWResults

    Dim LoadsAndRestraintsManagerObj As CosmosWorksLib.CWLoadsAndRestraintsManager

    Dim errCode As Long

    Dim motionStudyMgr As Object

    Dim el As Double, tl As Double, Tol1 As Double, Connector_Force As Double

 

    Set SwApp = Application.SldWorks

 

    'Set Part = SwApp.OpenDoc6("QAA_01_Cylindrical Bearing.SLDASM", swDocASSEMBLY, 192, "", longstatus, longwarnings)

    'If Part Is Nothing Then ErrorMsg2 SwApp, "Failed to open:QAA_01_Cylindrical Bearing.SLDASM", True

    'Set swAssembly = Part

    'SwApp.ActivateDoc2 "QAA_01_Cylindrical Bearing.SLDASM", False, longstatus

   

    Set Part = SwApp.ActiveDoc

 

    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 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

 

    Set motionStudyMgr = Part.Extension.GetMotionStudyManager()

 

    Set ActiveDocObj = COSMOSWORKSObj.ActiveDoc()

    If ActiveDocObj Is Nothing Then ErrorMsg2 SwApp, "No Active Document", True 'Get  the study

 

    Set StudyManagerObj = ActiveDocObj.StudyManager()

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

    StudyManagerObj.ActiveStudy = 1

    

    Dim StudyObj As Object

    Set StudyObj = StudyManagerObj.GetStudy(1)

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

 

    Part.GraphicsRedraw2

 

    Part.ViewZoomTo2 5.39264773386334E-02, 1.94101535368661E-02, 0.159999999986677, 9.33821942296391E-02, -2.38032506770925E-02, 0.159999999986677

 

    Part.GraphicsRedraw2

 

    Part.GraphicsRedraw2

   

    boolstatus = Part.Extension.SelectByRay(-4.30154869025614E-02, -2.3147631828806E-03, 8.69723354912821E-03, -0.851450358677067, -0.352944394561843, -0.387895012930133, 1.63979435633325E-04, 2, True, 0, 0)

 

    Part.GraphicsRedraw2

 

    Part.GraphicsRedraw2

 

    Part.GraphicsRedraw2

 

    Part.GraphicsRedraw2

   

    boolstatus = Part.Extension.SelectByRay(-4.45748406675648E-02, -9.87194045754336E-03, 4.85229755915384E-03, -0.851450358677067, -0.352944394561843, -0.387895012930133, 1.63979435633325E-04, 2, True, 0, 0)

 

    Part.GraphicsRedraw2

 

    Part.GraphicsRedraw2

       

    Set LoadsAndRestraintsManagerObj = StudyObj.LoadsAndRestraintsManager()

    Dim DispatchShaftObj As Object

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

    Dim DispatchHousingObj As Object

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

    Dim CWBearingConnector As ICWBearingConnector

    Set CWBearingConnector = LoadsAndRestraintsManagerObj.AddBearingConnector(DispatchShaftObj, DispatchHousingObj, errCode)

    If errCode <> 0 Then ErrorMsg2 SwApp, "Bearing connector creation failed", True

    If CWBearingConnector Is Nothing Then ErrorMsg2 SwApp, "Bearing connector creation failed", True

    errCode = CWBearingConnector.PerformAdvanceValidations

    If errCode <> 0 Then ErrorMsg2 SwApp, "Bearing connector PerformAdvanceValidations failed", True

   

    Set CWBearingConnector = LoadsAndRestraintsManagerObj.GetBearingConnector("Bearing Connector-2", errCode)

    If CWBearingConnector Is Nothing Then ErrorMsg2 SwApp, "GetBearingConnector failed", True

    CWBearingConnector.BeginEdit

    CWBearingConnector.ConnectionType = swsSpringConnType

    If errCode <> 0 Then ErrorMsg2 SwApp, "Bearing connector ConnectionType failed", True

    CWBearingConnector.UnitType = swsUnitSI

    If errCode <> 0 Then ErrorMsg2 SwApp, "Bearing connector UnitType failed", True

    CWBearingConnector.StiffnessType = swsBearingStiffnessRigid

    If errCode <> 0 Then ErrorMsg2 SwApp, "Bearing connector StiffnessType failed", True

    CWBearingConnector.AxialStiffnessValue = 0

    If errCode <> 0 Then ErrorMsg2 SwApp, "Bearing connector AxialStiffnessValue failed", True

    CWBearingConnector.LateralStiffnessValue = 0

    If errCode <> 0 Then ErrorMsg2 SwApp, "Bearing connector LateralStiffnessValue failed", True

    CWBearingConnector.TiltStiffnessValue = 0

    If errCode <> 0 Then ErrorMsg2 SwApp, "Bearing connector TiltStiffnessValue failed", True

    CWBearingConnector.StabilizeShaftRotation = False

    If errCode <> 0 Then ErrorMsg2 SwApp, "Bearing connector StabilizeShaftRotation failed", True

    errCode = CWBearingConnector.EndEdit()

    If errCode <> 0 Then ErrorMsg2 SwApp, "Bearing connector EndEdit failed", True

   

    Part.ClearSelection2 True

    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

 

    errCode = StudyObj.RunAnalysis

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

       

    Part.GraphicsRedraw2

 

    Set CWResult = StudyObj.Results

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

     

    'Get Connector results/Force

    'Dim Forc  As Variant

    'Forc = CWResult.GetConnectorForces2(1, "Bearing connector-2", 0, errCode)

 

    'Connector_Force = -528.28  'Expected axial force (comp = 7)

    'Tol1 = 0.1

 

    'Dim i As Integer

    'For i = 0 To 10

    '   Debug.Print i & " : " & Forc(i)

    '   SwApp.RecordLine "'******** Bearing connector Force " & i & " : " & Forc(i) & " ********"

    'Next i

   

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

    'Connector force comparision.

    'If ((Forc(7)) = nan) Then

    'ErrorMsg2 SwApp, "Forc(7) is not calculated ", False

    'End If

   

    'If ((Forc(7)) < 0.95 * Connector_Force) Or ((Forc(7)) > 1.05 * Connector_Force) Then

    'ErrorMsg2 SwApp, "O/p Force % error = " & (((Forc(7) - Connector_Force) / Connector_Force) * 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 ""

    'If EndTest Then

    'SwApp.ExitApp

    'End

    'End If

End Function

Example

Remarks

For more information about bearing connectors, see the SOLIDWORKS user-interface help > Simulation > Loads and Restraints > Connectors > Bearing Connectors Between Parts topics.

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:   ICWBearingConnector 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) 2024 SP04

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.