Working on an assembly or part? And what type? (Beam(s),Low thickness, mechanically welded... other)
It would be interesting to have an idea of the geometry (1000 faces ???) on which you apply your force of 1N (1Newton, it's not much... Wouldn't it be easier to play with gravity, or with the masses? … My curiosity won't mind a little screenshot ... or better the *.sld file... (Solidworks 2019 (that's old-fashioned: 2019) has the advantage to be able to be exploited by a large number of the forumists present here...
Thanks for the interest in the topic! The static study is done either in a part file or on a part in an assembly. In all cases, the part is a volume (extrusion) of about 1.6mm thick. I can provide a sld file in private message if needed.
Arf I only know that... That explains the 1.6mm, I could have thought of it but for there to be 1000 faces, either it has a damn original shape, full of holes and cutouts, or you include the components but there it changes everything to the simulation.
I guess the fixed support points you're talking about are the areas where the PCB is held and fixed.
Is the purpose of the simulation to simulate a deformation of the PCB, if for example it is in a flexible case, or to simulate its deformation if an object presses on it?
@Sylk I metrise the Force and its extraordinary abilities, such as telekinesis, clairvoyance, and mind manipulation. I have been trained in the art of self-control and meditation. but with solidworks we are in another world, only Dassault has control over it... in fact no I think that even we don't know
FYI, here is the code I use to insert the force at each surface in the loop:
Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Sub insert_force(DispatchObj1 As Object)
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Dim COSMOSWORKSObj As Object
Dim CWAddinCallBackObj As Object
Set CWAddinCallBackObj = swApp.GetAddInObject("CosmosWorks.CosmosWorks")
Set COSMOSWORKSObj = CWAddinCallBackObj.COSMOSWORKS
Dim ActiveDocObj As Object
Dim StudyManagerObj As Object
Dim LoadsAndRestraintsManagerObj As Object
Dim ErrorCodeObj As Long
Dim ContactManagerObj As Object
Set ActiveDocObj = COSMOSWORKSObj.ActiveDoc()
Set StudyManagerObj = ActiveDocObj.StudyManager()
Dim StudyObj As Object
Set StudyObj = StudyManagerObj.GetStudy(0)
Set LoadsAndRestraintsManagerObj = StudyObj.LoadsAndRestraintsManager()
DispArray = Array(DispatchObj1) 'Récupération de la surface
Dim CWForceObj As Object
Dim DistanceValues As Variant
Dim ForceValues As Variant
Dim ComponentValues As Variant
Dim data(6) As Double
data(0) = 1
data(1) = 1
data(2) = 1
data(3) = 1
data(4) = 1
data(5) = 1
ComponentValues = data
Set CWForceObj = LoadsAndRestraintsManagerObj.AddForce3(1, 0, -1, 0, 0, 0, (DistanceValues), (ForceValues), 0, False, 0, 0, 0, 1, (ComponentValues), False, False, (DispArray), Nothing, False, ErrorCodeObj)
' Redraw
Part.GraphicsRedraw2
Set StudyManagerObj = Nothing
Set ActiveDocObj = Nothing
Set CWAddinCallBackObj = Nothing
Set COSMOSWORKSObj = Nothing
End Sub
But how do you " group " several surfaces into a " batch " that would be called by the insert command??? Unless it's not the right logic??
Hello fgauvreau, Try this. It will run through the selection games and create a hidden force for everyone (though without the step of creating it just on the first side. I may not have understood the reason for this step)
Option Explicit
Dim swApp As SldWorks.SldWorks
Sub main()
Dim swModel As SldWorks.ModelDoc2
Dim swFeat As SldWorks.Feature
Dim swSelectionSetFolder As SldWorks.SelectionSetFolder
Dim vSels As Variant
Dim vSel As Variant
Dim swSelSet As SldWorks.SelectionSet
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swFeat = swModel.FirstFeature
While Not swFeat Is Nothing
If swFeat.Name = "Selection Sets" Then
Set swSelectionSetFolder = swFeat.GetSpecificFeature2
vSels = swSelectionSetFolder.GetSelectionSets
For Each vSel In vSels
Set swSelSet = vSel
Debug.Print "Nom du jeu de Selection: " & swSelSet.GetName
swModel.ClearSelection2 True
CreateForce swSelSet
Next
End If
Set swFeat = swFeat.GetNextFeature
Wend
End Sub
Sub CreateForce(swSelSet As SldWorks.SelectionSet)
Dim COSMOSWORKSObj As Object
Dim CWAddinCallBackObj As Object
Set CWAddinCallBackObj = swApp.GetAddInObject("CosmosWorks.CosmosWorks")
Set COSMOSWORKSObj = CWAddinCallBackObj.COSMOSWORKS
Dim ActiveDocObj As Object
Dim StudyManagerObj As Object
Dim LoadsAndRestraintsManagerObj As Object
Dim ErrorCodeObj As Long
Dim ContactManagerObj As Object
Set ActiveDocObj = COSMOSWORKSObj.ActiveDoc()
Set StudyManagerObj = ActiveDocObj.StudyManager()
Dim StudyObj As Object
Set StudyObj = StudyManagerObj.GetStudy(0)
Set LoadsAndRestraintsManagerObj = StudyObj.LoadsAndRestraintsManager()
Dim vSelItems As Variant
Dim vSelItemTypes As Variant
Dim swSelItem As SldWorks.SelectionSetItem
Dim swFace As SldWorks.Face2
Dim j As Integer
vSelItems = swSelSet.GetSelectionSetItems
vSelItemTypes = swSelSet.GetSelectionSetItemTypes
Dim DispArray As Variant
Dim cnt As Long
cnt = UBound(vSelItems)
Dim myArray()
ReDim Preserve myArray(cnt)
For j = 0 To cnt
Set swSelItem = vSelItems(j)
'If vSelItemTypes(j) = swSelectType_e.swSelFACES Then
Set myArray(j) = swSelItem.GetCorrespondingItem
'End If
Next
DispArray = myArray
Dim CWForceObj As Object
Dim DistanceValues As Variant
Dim ForceValues As Variant
Dim ComponentValues As Variant
Dim data(6) As Double
data(0) = 1: data(1) = 1: data(2) = 1: data(3) = 1: data(4) = 1: data(5) = 1
ComponentValues = data
Set CWForceObj = LoadsAndRestraintsManagerObj.AddForce3(1, 0, -1, 0, 0, 0, (DistanceValues), (ForceValues), 0, False, 0, 0, 0, 1, (ComponentValues), False, False, (DispArray), Nothing, False, ErrorCodeObj)
StudyObj.ShowOrHideForce = False
Set StudyManagerObj = Nothing
Set ActiveDocObj = Nothing
Set CWAddinCallBackObj = Nothing
Set COSMOSWORKSObj = Nothing
End Sub
Thank you very much! That's exactly what I needed... I was able to integrate the code into my macro by managing the value of the force according to the selection game and creating fixed supports on the same principle.
StudyObj.ShowOrHideForce = FalseTexte préformaté nickel to lighten the treatment!