Dim CWAddinCallBackObj As Object
CWAddinCallBackObj=Swapp. GetAddInObject (" CosmosWorks. CosmosWorks ")
COSMOSWORKSObj=CWAddinCallBackObj. COSMOSWORKS
'the Redraw
Part. GraphicsRedraw2 ()
Dim motionStudyMgr As Object
MotionStudyMgr=Part. The Extension. GetMotionStudyManager ()
Dim ActiveDocObj As Object
Dim StudyManagerObj As Object
Dim LoadsAndRestraintsManagerObj As Object
Dim ErrorCodeObj As Integer
Dim ContactManagerObj As Object
ActiveDocObj=COSMOSWORKSObj. ActiveDoc ()
StudyManagerObj=ActiveDocObj. StudyManager ()
StudyManagerObj. ActiveStudy=0
Dim NewStudyName As String
NewStudyName="1" static stress analysis
Dim CWNewStudy As Object
CWNewStudy=StudyManagerObj. CreateNewStudy3 (NewStudyName, 0, 0, ErrorCodeObj)
Part. ClearSelection2 (True)
Part. The Extension. SelectByID2 (" removal - stretching 1 ", "SOLIDBODY", 0, 0, 0, True, 0, Nothing, 0)
Dim StudyObj As Object
StudyObj=StudyManagerObj. GetStudy (0)
Dim SolidManagerObj As Object
SolidManagerObj=StudyObj. SolidManager ()
Solidworks ErrorCodeObj=SolidManagerObj. SetLibraryMaterialToSelectedEntities (" materials ", "casting alloy steel")
Part. ClearSelection2 (True)
LoadsAndRestraintsManagerObj=StudyObj. LoadsAndRestraintsManager ()
Dim DispatchObj1 As Object
DispatchObj1=Part. SelectionManager. GetSelectedObject6 (1, 1)
Dim DispArray As Object ()={DispatchObj1}
Dim CWForceObj As Object
Dim DistanceValues As Object=Nothing
Dim ForceValues As Object=Nothing
Dim ComponentValues As Object
Dim data (5) As a Double
Data (0)=1.0 #
Data (1)=1.0 #
Data (2)=1.0 #
Data (3)=1.0 #
Data (4)=1.0 #
Data (5)=1.0 #
ComponentValues={data (0), data (1), data (2), data (3), data (4), data (5)}
CWForceObj=LoadsAndRestraintsManagerObj. AddForce3 (1, 0, 1, 0, 0, 0, DistanceValues, ForceValues, 0, False, 0, 0, 0, 2.012, ComponentValues, False, False, DispArray, Nothing, False, ErrorCodeObj) error '
in this placePart. ClearSelection2 (True)
CodePudding user response:
ComponentValues should be the array type is wrong, write some questions,Dim ComponentValues=new double () {# # # 1.0, 1.0, 1.0, 1.0, 1.0 #}
CWForceObj=LoadsAndRestraintsManagerObj. AddForce3 (1, 0, 1, 0, 0, 0, DistanceValues, ForceValues, 0, False, 0, 0, 0, 2.012, ComponentValues, False, False, DispArray, Nothing, False, ErrorCodeObj)
CodePudding user response:
SW of secondary development, record the macro code, there are some major changes to it