"sw-ground" properties in the welded part list

Hello Twathle,
Back for my last message, here is my tutorial for information =>https://mycad.visiativ.com/contenu/ajout-la-masse-pour-chaque-corps-dun-mécanosoudé-dans-sa-liste-de-piéces-soudées?tuto
And here is also the model of the " Welded Parts List", make good use of it!! OL. :wink:
EssaiListePiécesSoudée.zip (1.9 KB)

1 Like

Hello
What is unfortunate is that you have to fill in the mass property for each item in the welded parts list. That said, it works well.
Another solution is to enter the ground property for each profile... :face_with_spiral_eyes:

1 Like

Hello Le_Bidule,

And yes indeed you have to inform.
It's possible with a macro, but I don't know how to do it ... @+.
AR.

Hello;

Here is a small macro to automatically add the " Mass " property on all mechanically welded elements (Welded Parts List):
=> If specific materials are assigned to certain elements they will be taken into account, otherwise the density of the Global material is kept...

Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swFeat As SldWorks.Feature
Dim swCustPropMgr As SldWorks.CustomPropertyManager
Dim FileName As String

Sub main()
On Error Resume Next

Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc

If swModel Is Nothing Then
MsgBox "Pas de fichier Pièce Solidworks actif..."
End
End If

If swModel.GetType <> 1 Then
MsgBox "Pas de fichier Pièce Solidworks actif..."
End
End If

'swModel.Save

FileName = Mid(swModel.GetPathName, InStrRev(swModel.GetPathName, "\") + 1)

Set swFeat = swModel.FirstFeature
Do While Not swFeat Is Nothing
If swFeat.GetTypeName() = "CutListFolder" Then
Set swCustPropMgr = swFeat.CustomPropertyManager
swCustPropMgr.Add3 "Masse", swCustomInfoText, Chr(34) & "SW-Mass@@@" & swFeat.Name & "@" & FileName & Chr(34) & " Kg", 1
End If
Set swFeat = swFeat.GetNextFeature
Loop
End Sub

Note: it is possible to customize the line.
swCustPropMgr.Add3 " Mass ", swCustomInfoText, Chr(34) & " SW-Mass@@@ " & swFeat.Name & " @ " & FileName & Chr(34) & " Kg", 1

=> " Mass " is the Name of the property to be created
=> & " Kg " (optional text)

Macro for use exclusively on Solidworks Parts files.

Kind regards.

3 Likes

@Cyril.f I temporarily suspended your " Best Answer " to bring up this discussion... But I keep in mind the value of your answer. :yum:

1 Like

I don't chase the best answers :wink:

1 Like