Creating a Sheet Metal Thickness Property with BatchProperties

Hello

In order to update the properties of my old parts, I would like to use BatchProperties to create a " THICKNESS " property that is set to the thickness of my part. I would like to create this new property en masse on our pieces.

When I create the property with batchproperties, it is generated but has no value:

image

I have tried to assign the thickness of the part to my property in several ways "Value of a Solidworks property" or "Value 1st article list of welded parts" but the problem persists.

image

Does anyone have the solution to my problem?

Thank you

Kind regards

Hello;

Currently, if I rely on the screenshots , you are asking BatchProperties to retrieve the value of the " Thickness " property to create the " Thickness" property, this cannot work...
If your older parts are indeed sheet metal components, the Thickness is written in the global variables (equation), or in the " Sheet Metal Thickness" welded parts list properties such as " SW-tôlerie@@ Thickness@Article-Welded-Parts-List1@LeNomdelaPièce.SLDPRT "
(right click on the list of parts welded in one of your sheet metal parts).
: "So it's one or another value that we will have to go for.

For the time being, I don't know how to do it with the MyCad tools (probably with a macro would be the most practical)... I'll look on my side but if anyone has an idea in the meantime...

A macro track to adapt here:
https://www.codestack.net/solidworks-api/data-storage/custom-properties/link-sheet-metal/
or even simpler with the macro of our friends @JeromeP :
https://forum.mycad.visiativ.com/t/macro-pour-ajouter-des-proprietes-suivant-epaisseur-de-tole/99011/6?lang=en&locale=fr

1 Like

Hello

Thank you for this information.

On the myCAD tools I can find the thickness via the sw variables:

image

But in Batchproperties I don't have access to SW variables.

I'll try to create a MACRO and then apply it in bulk.

The solution I use that is a bit wobbly

If several sheet metal bodies will be Russian roulette, the best: 1 single piece of sheet metal

image

Sometimes the macro doesn't work
especially if the sheet metal part name: Welded Parts List is renamed
in general I test the macro directly in SW I check that the properties are copied, I restart if necessary, several times and I count the number of times I had to launch the macro

since integration I run the number of times I have done it manually (on other parts)

It's a bit wobbly, create a bill of materials with the properties and open and manually launch the macro on the few parts where there is a PB

this macro does not work for older versions of SW, you can read oddities in the soldered parts properties especially if the part is copied and renamed, the old part name appears and even if manually you put the new one it does not work

this is due in my opinion to the fact that in SW there is no hard-coded name (in English) and identifiable by this means unlike the name of functions which even if they are renamed keep a default name in English like the constraints ... (a macro I worked on to rename functions downloaded from other languages)

Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swFeat As SldWorks.Feature
Dim swCustPropMgr As SldWorks.CustomPropertyManager
Dim cutListCustPropMgr As SldWorks.CustomPropertyManager
Dim PROP_TOLERIE As Variant
Dim PROP_PERSO As Variant
Dim i As Integer

Sub Copie_01()
'Copie les propriétés de pièces soudées vers propriétés personnalisées

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

If (swModel.GetType <> 1) Then '1 = pièce, 2 = assemblage, 3 = plan
MsgBox "Pièce uniquement", vbInformation
Exit Sub
End If


PROP_TOLERIE = Array("Longueur du flanc de tôle", "Largeur du flanc de tôle", "Longueur à découper extérieure", _
               "Longueur à découper des boucles intérieures", "Découpes", "Plis")
PROP_PERSO = Array("Long flanc", "Larg flanc", "Long découpe ext.", _
             "Long découpe int.", "Découpes", "Plis")


Set swCustPropMgr = swModel.Extension.CustomPropertyManager("")

For i = 0 To UBound(PROP_PERSO)
swCustPropMgr.Delete PROP_PERSO(i)
Next i

swCustPropMgr.Delete "Epaisseur"
swCustPropMgr.Add2 "Epaisseur", swCustomInfoType_e.swCustomInfoText, """" & "Epaisseur@" & swModel.GetTitle() & ".SLDPRT" & """"

Set swFeat = swModel.FirstFeature
Do While Not swFeat Is Nothing
Debug.Print swFeat.GetTypeName

If swFeat.GetTypeName = "CutListFolder" Then
Dim swBodyFolder As SldWorks.BodyFolder
Set swBodyFolder = swFeat.GetSpecificFeature2
swBodyFolder.SetAutomaticCutList (True)
swBodyFolder.UpdateCutList
Set cutListCustPropMgr = swFeat.CustomPropertyManager
    
    For i = LBound(PROP_TOLERIE) To UBound(PROP_TOLERIE)
    Dim valOut As String
    Dim resolvedValOut As String
    cutListCustPropMgr.Get4 PROP_TOLERIE(i), True, valOut, resolvedValOut
        
        If valOut <> "" Then
        swCustPropMgr.Add2 PROP_PERSO(i), swCustomInfoType_e.swCustomInfoText, valOut
        End If
        
    Next i
End If
Set swFeat = swFeat.GetNextFeature
Loop
End Sub