Bonjour
Ci dessous une macro qui créé des propriétés personnalisées sur le fichier et sur les configurations (pompée chez SW et adaptée par nous vu les commentaires):
' ----------------------------------------------
' Postconditions: The custom property Input1 is added to the file.
' NOTE: Because configurations are not supported in drawings, pass a blank string when the file is a drawing.
'------------------------------------------------
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim retval As String
Dim vConfigNameArr As Variant
Dim vConfigName As Variant
Dim swActiveConf As SldWorks.Configuration
Dim swConf As SldWorks.Configuration
Dim swConfMgr As SldWorks.ConfigurationManager
Dim swDerivConf As SldWorks.Configuration
Dim bRet As Boolean
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swConfMgr = swModel.ConfigurationManager
Set swConfig = swConfMgr.ActiveConfiguration
vConfigNameArr = swModel.GetConfigurationNames
retval = swModel.AddCustomInfo3("", "IsFastener", swCustomInfoYesOrNo, "No")
retval = swModel.AddCustomInfo3("", "Bibliotheque", swCustomInfoYesOrNo, "No")
retval = swModel.AddCustomInfo3("", "Piece_standard", swCustomInfoYesOrNo, "No")
retval = swModel.AddCustomInfo3("", "Rechange", swCustomInfoText, "-")
retval = swModel.AddCustomInfo3("", "Repère", swCustomInfoText, "0")
retval = swModel.AddCustomInfo3("", "Repère_soudure", swCustomInfoText, "-")
retval = swModel.AddCustomInfo3("", "Révision", swCustomInfoText, "-")
vConfigNameArr = swModel.GetConfigurationNames
For Each vConfigName In vConfigNameArr
Set swConf = swModel.GetConfigurationByName(vConfigName)
' Do not assert; will be NULL if (derived) configuration already exists
retval = swModel.AddCustomInfo3(swConf.Name, "Numero_plan", swCustomInfoText, "$PRPSHEET:""SW-Nom de fichier(File Name)""")
retval = swModel.AddCustomInfo3(swConf.Name, "Description_Francais", swCustomInfoText, "-")
retval = swModel.AddCustomInfo3(swConf.Name, "Description_Francais_2", swCustomInfoText, "-")
retval = swModel.AddCustomInfo3(swConf.Name, "Observation", swCustomInfoText, "-")
retval = swModel.AddCustomInfo3(swConf.Name, "Weight", swCustomInfoText, """SW-Mass@@Défaut@ModelDoc2.SLDPRT""")
retval = swModel.AddCustomInfo3(swConf.Name, "Material", swCustomInfoText, """SW-Material@@Défaut@ModelDoc2.SLDPRT""")
retval = swModel.AddCustomInfo3(swConf.Name, "CREATIONAUTO", swCustomInfoText, "NON")
Next
MsgBox retval
End Sub
' ----------------------------------------------