Hide Table of Contents

Get COSMOSMotion Motion Study Properties and Results Example (VBA)

This example shows how to get a COSMOSMotion motion study's properties and results.

 

'------------------------------------------

' Preconditions: Model is open that has a COSMOSMotion motion study

'                named PhysSim and at least one COSMOSMotion motion study plot.

'

' Postconditions: None

'--------------------------------------------

Option Explicit

 

Dim swApp As SldWorks.SldWorks

Dim swModel As SldWorks.ModelDoc2

Dim swModelDocExt As SldWorks.ModelDocExtension

Dim swMotionMgr As SwMotionStudy.MotionStudyManager

Dim swMotionStudy1 As SwMotionStudy.MotionStudy

Dim swResults As SwMotionStudy.MotionStudyResults

Dim swMotionStudyProps As SwMotionStudy.MotionStudyProperties

Dim swCosmosMotionStudyProps As SwMotionStudy.CosmosMotionStudyProperties

Dim swCosmosMotionStudyResults As SwMotionStudy.CosmosMotionStudyResults

 

Sub main()

    Set swApp = Application.SldWorks

    Set swModel = swApp.ActiveDoc

    Set swModelDocExt = swModel.Extension

    ' Get the MotionManager.

    Set swMotionMgr = swModelDocExt.GetMotionStudyManager()

    If (swMotionMgr Is Nothing) Then

          End

    End If

    ' Get motion study named PhysSim.

    Set swMotionStudy1 = swMotionMgr.GetMotionStudy("PhysSim")

    If (swMotionStudy1 Is Nothing) Then

        MsgBox "PhysSim is not available."

        End

    End If

    

    swMotionStudy1.StudyType = swMotionStudyType_e.swMotionStudyTypePhysicalSimulation

    

    'Is the motion study active?  If not, activate it.

    If Not swMotionStudy1.IsActive Then swMotionStudy1.Activate

    Debug.Print "Duration of motion study: " & swMotionStudy1.GetDuration

    Debug.Print "Timebar position on timeline: " & swMotionStudy1.GetTime

    Debug.Print "Number of motion features: " & swMotionStudy1.GetMotionFeaturesCount

    

    'Get COSMOSMotion study properties.

    Set swMotionStudyProps = swMotionStudy1.GetProperties(4)

    Set swCosmosMotionStudyProps = swMotionStudyProps

        

    Debug.Print ""

    Debug.Print "COSMOSMotion study properties: "

    Debug.Print "    Animate during simulation: " & swCosmosMotionStudyProps.AnimateDuringSimulation

    Debug.Print "    Make all mates flexible: " & swCosmosMotionStudyProps.MakeAllMatesFlexible

    Debug.Print "    Display results graphics as wireframe: " & swCosmosMotionStudyProps.WireframeGraphics

 

    ' Get COSMOSMotion study results.

    Set swResults = swMotionStudy1.GetResults(4)

    Set swCosmosMotionStudyResults = swResults

    Debug.Print "    Number of plots: " & swCosmosMotionStudyResults.GetPlotCount

    

    Debug.Print ""

    Debug.Print "Are the motion study results out of date? " & swResults.IsOutOfDate

    

     

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 COSMOSMotion Motion Study Properties and Results Example (VBA)
*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.