Et voici Mon bout de code avec lequel j'essai d'avancer :
Dim swApp As Object
Dim Part As Object
Dim boolstatus As Boolean
Dim longstatus As Long, longwarnings As Long
Sub main()
Set swApp = _
Application.SldWorks
'Ouvrir Pièce
Set Part = swApp.OpenDoc6("C:\Users\ad36aaen\Documents\Utilisat\Conception SdC\1300\Structures de base\Structures\Matériels\Matériels.SLDPRT", 1, 0, "", longstatus, longwarnings)
swApp.ActivateDoc2 "Matériels.SLDPRT", False, longstatus
Set Part = swApp.ActiveDoc
Set Part = swApp.ActiveDoc
Dim myModelView As Object
Set myModelView = Part.ActiveView
myModelView.FrameLeft = 0
myModelView.FrameTop = 0
Set myModelView = Part.ActiveView
myModelView.FrameState = swWindowState_e.swWindowMaximized
Set myModelView = Part.ActiveView
myModelView.FrameState = swWindowState_e.swWindowMaximized
'Boucle for i=1 to 50(=NbrFic)... enf if
'Plan
boolstatus = Part.Extension.SelectByID2("Plan 4mm", "PLANE", 0, 0, 0, False, 0, Nothing, 0)
'Image d'equisse
Part.SketchManager.InsertSketch True
Dim SkPicture As Object
'Il faut lister, pas insérer : commande Dir
'Il faut récupérer le nom de l'image dés qu'on l'insère
Set SkPicture = Part.SketchManager.InsertSketchPicture("C:\Users\ad36aaen\Documents\Utilisat\Conception SdC\1300\Structures de base\Structures\Matériels\Photos matériels\P01\HO\TPL_REA390TL.png")
Part.ClearSelection2 True
Part.SketchManager.InsertSketch True
boolstatus = Part.Extension.SelectByID2("Esquisse220", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("Esquisse220", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)
'Nom esquisse
boolstatus = Part.SelectedFeatureProperties(0, 0, 0, 0, 0, 0, 0, 1, 0, "1")
boolstatus = Part.Extension.SelectByID2("Image d'esquisse1577", "SKETCHBITMAP", 0, 0, 0, False, 0, Nothing, 0)
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("Image d'esquisse1577", "SKETCHBITMAP", 0, 0, 0, False, 0, Nothing, 0)
'Nom image d'esquisse
boolstatus = Part.SelectedFeatureProperties(0, 0, 0, 0, 0, 0, 0, 1, 0, "2")
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("1", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)
boolstatus = Part.Extension.SelectByID2("1", "SKETCH", 0, 0, 0, False, 0, Nothing, 0)
'Dossier
Dim myFeature As Object
Set myFeature = Part.FeatureManager.InsertFeatureTreeFolder2(swFeatureTreeFolderType_e.swFeatureTreeFolder_Containing)
boolstatus = Part.SelectedFeatureProperties(0, 0, 0, 0, 0, 0, 0, 1, 0, "3")
'Configuration
boolstatus = Part.Extension.SelectByID2("Défaut", "CONFIGURATIONS", 0, 0, 0, False, 0, Nothing, 0)
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("4", "CONFIGURATIONS", 0, 0, 0, False, 0, Nothing, 0)
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("4", "CONFIGURATIONS", 0, 0, 0, False, 0, Nothing, 0)
'Nom configuration
boolstatus = Part.SelectedFeatureProperties(15651274, 1, 1, 0.5, 0.400000005960464, 0, 0, 0, 0, "5")
Part.ClearSelection2 True
boolstatus = Part.Extension.SelectByID2("2", "SKETCHBITMAP", 2.22464985227471E-02, 4.0000000000191E-03, -5.56639089934266E-02, False, 0, Nothing, 0)
Part.ClearSelection2 True
End Sub