CATIA V5 | 3DEXPERIENCE
Vous souhaitez réagir à ce message ? Créez un compte en quelques clics ou connectez-vous pour continuer.
Le deal à ne pas rater :
Jeux, jouets et Lego : le deuxième à -50% (large sélection)
Voir le deal

Ajout automatique de visserie

3 participants

Aller en bas

Ajout automatique de visserie Empty Ajout automatique de visserie

Message par Liocco08 Mar 19 Mar 2024 - 9:10

Bonjour à tous,

Encore une question macro, ces derniers temps j'arrête pas ^^

Au quotidien on se rend compte que l'ajout de visserie dans nos conceptions nous prends un temps fou (on parle d'assemblage de milliers de pièces) et alourdit énormément le modèle, de ce fait on a tendance à négliger cet aspect qui nous réserve parfois des surprises (visserie impossible à installer, rondelle qui clash avec de la matière ou des cordons de soudures...)

Je réfléchissais (outre l'installation de la visserie qui doit être vérifié par le concepteur) à créer une macro qui ajoute automatiquement la visserie. De mémoire ça existe sur d'autre soft de CAO que Catia. Évidemment il faut l'imaginer en VBA, donc mon idée était d'avoir une interface utilisateur avec plusieurs données d'entrées :

- L'axe permettant de positionner la visserie
- La face supérieure permettant d’orienter la visserie
- Une liste avec quel type de visserie, et sa longueur


A voir si l'on rajoute une 2ème face pour automatiser le calcul de la longueur prenant en compte la taille de rondelle + écrou + 2 filets qui dépasse ?

Enfin voilà, de part votre expérience vous pensez que c'est réalisable ou que c'est un doux rêve qu'il est préférable d'oublier ?

Merci à vous,

Julien

Liocco08
actif
actif

Messages : 39
Date d'inscription : 07/04/2022
Localisation : Toulouse

Revenir en haut Aller en bas

Ajout automatique de visserie Empty Re: Ajout automatique de visserie

Message par lumpazepfel Mer 20 Mar 2024 - 10:32

Salut Julien,

Sujet intéressant, je ne sais pas quel niveau d’automatisation on peut atteindre, mais ça vaut le coup d'essayer.
Je pense qu'il faudrait utiliser les publications pour positionner la visserie.
D'où ma première question : comment sont enregistrées les CATPArt de visserie?
lumpazepfel
lumpazepfel
Fédérateur
Fédérateur

Messages : 316
Date d'inscription : 02/11/2015
Localisation : Ensisheim

Revenir en haut Aller en bas

Ajout automatique de visserie Empty Re: Ajout automatique de visserie

Message par Flo42 Mer 20 Mar 2024 - 14:48

Bonjour,

J'avais commencé à bosser sur un sujet similaire au votre :Ajout automatique de visserie Macro_11

voici le code associé :
Code:
Public MaVis As Product

Private Sub ComboBox1_Change()
Dim toto As String
Dim repertoire As String, fichierCatia As String
ListBox2.Clear
ComboBox2.Clear
If ComboBox1.Value = "M2.5" Then
ComboBox2.AddItem "4"
ComboBox2.AddItem "5"
ComboBox2.AddItem "6"
ComboBox2.AddItem "8"
ComboBox2.AddItem "10"
ComboBox2.AddItem "12"
ComboBox2.AddItem "16"
ComboBox2.AddItem "20"
ComboBox2.AddItem "25"
End If
'== ci-dessous pour Chc M3
If ComboBox1.Value = "M3" And OptionButton2.Value = True Then
ListBox1.Clear
    repertoire = "\\Liens vers vos bibliohèque de vis\" 'cela demande de classé vos vis dans des sous répertoire par taille (m3 m4 m6 etc)
    fichierCatia = Dir(repertoire & "*M3*")
    Do While fichierCatia <> ""
        ListBox2.AddItem fichierCatia
        If InStr(fichierCatia, "M") > 0 Then 'si la ligne de mon tableau virtuel contient la lettre "M"
        toto = Split(fichierCatia, "M")(1) 'alors la variable toto est égale à tout ce qui se trouve devant M
        toto = Left(toto, 4)
        toto = Replace(toto, "_", " ")
        Me.ListBox1.AddItem "VIS CHC M" & toto
        End If
        Me.ListBox1.ColumnCount = 1
        Me.ListBox1.ColumnWidths = "100"
        'Me.ListBox1.AddItem "VIS CHC M" & toto
        fichierCatia = Dir
    Loop
End If
'==
'== ci-dessous pour Chc M4
If ComboBox1.Value = "M4" And OptionButton2.Value = True Then
ListBox1.Clear
    repertoire = "\\Liens vers vos bibliohèque de vis\"
    fichierCatia = Dir(repertoire & "*M4*")
    Do While fichierCatia <> ""
    ListBox2.AddItem fichierCatia
        If InStr(fichierCatia, "M") > 0 Then 'si la ligne de mon tableau virtuel contient la lettre "X"
        toto = Split(fichierCatia, "M")(1) 'alors la variable toto est égale à tout ce qui se trouve devant X
        toto = Left(toto, 4)
        toto = Replace(toto, "_", " ")
        Me.ListBox1.AddItem "VIS CHC M" & toto
        End If
        Me.ListBox1.ColumnCount = 1
        Me.ListBox1.ColumnWidths = "100"
        'Me.ListBox1.AddItem "VIS CHC M" & toto
        fichierCatia = Dir
    Loop
End If
'==
'== ci-dessous pour Chc M5
If ComboBox1.Value = "M5" And OptionButton2.Value = True Then
ListBox1.Clear
    repertoire = "\\Liens vers vos bibliohèque de vis\"
    fichierCatia = Dir(repertoire & "*M5*")
    Do While fichierCatia <> ""
    ListBox2.AddItem fichierCatia
        If InStr(fichierCatia, "M") > 0 Then 'si la ligne de mon tableau virtuel contient la lettre "X"
        toto = Split(fichierCatia, "M")(1) 'alors la variable toto est égale à tout ce qui se trouve devant X
        toto = Left(toto, 5)
        toto = Replace(toto, "_", " ")
        Me.ListBox1.AddItem "VIS CHC M" & toto
        End If
        Me.ListBox1.ColumnCount = 1
        Me.ListBox1.ColumnWidths = "100"
        'Me.ListBox1.AddItem "VIS CHC M" & toto
        fichierCatia = Dir
    Loop
End If
'==
'== ci-dessous pour Chc M6
If ComboBox1.Value = "M6" And OptionButton2.Value = True Then
ListBox1.Clear
    repertoire = "\\Liens vers vos bibliohèque de vis\"
    fichierCatia = Dir(repertoire & "*M6*")
    Do While fichierCatia <> ""
    ListBox2.AddItem fichierCatia
        If InStr(fichierCatia, "M") > 0 Then 'si la ligne de mon tableau virtuel contient la lettre "X"
        toto = Split(fichierCatia, "M")(1) 'alors la variable toto est égale à tout ce qui se trouve devant X
        toto = Left(toto, 5)
        toto = Replace(toto, "_", " ")
        Me.ListBox1.AddItem "VIS CHC M" & toto
        End If
        Me.ListBox1.ColumnCount = 1
        Me.ListBox1.ColumnWidths = "100"
        'Me.ListBox1.AddItem "VIS CHC M" & toto
        fichierCatia = Dir
    Loop
End If
'==
'== ci-dessous pour Chc M8
If ComboBox1.Value = "M8" And OptionButton2.Value = True Then
ListBox1.Clear
    repertoire = "\\Liens vers vos bibliohèque de vis\"
    fichierCatia = Dir(repertoire & "*M8*")
    Do While fichierCatia <> ""
    ListBox2.AddItem fichierCatia
        If InStr(fichierCatia, "M") > 0 Then 'si la ligne de mon tableau virtuel contient la lettre "X"
        toto = Split(fichierCatia, "M")(1) 'alors la variable toto est égale à tout ce qui se trouve devant X
        toto = Left(toto, 5)
        toto = Replace(toto, "_", " ")
        Me.ListBox1.AddItem "VIS CHC M" & toto
        End If
        Me.ListBox1.ColumnCount = 1
        Me.ListBox1.ColumnWidths = "100"
        'Me.ListBox1.AddItem "VIS CHC M" & toto
        fichierCatia = Dir
    Loop
End If
'==
'== ci-dessous pour Chc M10
If ComboBox1.Value = "M10" And OptionButton2.Value = True Then
ListBox1.Clear
    repertoire = "\\Liens vers vos bibliohèque de vis\"
    fichierCatia = Dir(repertoire & "*M10*")
    Do While fichierCatia <> ""
    ListBox2.AddItem fichierCatia
        If InStr(fichierCatia, "M") > 0 Then 'si la ligne de mon tableau virtuel contient la lettre "X"
        toto = Split(fichierCatia, "M")(1) 'alors la variable toto est égale à tout ce qui se trouve devant X
        toto = Left(toto, 6)
        toto = Replace(toto, "_", " ")
        Me.ListBox1.AddItem "VIS CHC M" & toto
        End If
        Me.ListBox1.ColumnCount = 1
        Me.ListBox1.ColumnWidths = "100"
        'Me.ListBox1.AddItem "VIS CHC M" & toto
        fichierCatia = Dir
    Loop
End If
'==
'== ci-dessous pour Chc M12
If ComboBox1.Value = "M12" And OptionButton2.Value = True Then
ListBox1.Clear
    repertoire = "\\Liens vers vos bibliohèque de vis\"
    fichierCatia = Dir(repertoire & "*M12*")
    Do While fichierCatia <> ""
    ListBox2.AddItem fichierCatia
        If InStr(fichierCatia, "M") > 0 Then 'si la ligne de mon tableau virtuel contient la lettre "X"
        toto = Split(fichierCatia, "M")(1) 'alors la variable toto est égale à tout ce qui se trouve devant X
        toto = Left(toto, 6)
        toto = Replace(toto, "_", " ")
        Me.ListBox1.AddItem "VIS CHC M" & toto
        End If
        Me.ListBox1.ColumnCount = 1
        Me.ListBox1.ColumnWidths = "100"
        'Me.ListBox1.AddItem "VIS CHC M" & toto
        fichierCatia = Dir
    Loop
End If
'==
'== ci-dessous pour Chc M14
If ComboBox1.Value = "M14" And OptionButton2.Value = True Then
ListBox1.Clear
    repertoire = "\\Liens vers vos bibliohèque de vis\"
    fichierCatia = Dir(repertoire & "*M14*")
    Do While fichierCatia <> ""
    ListBox2.AddItem fichierCatia
        If InStr(fichierCatia, "M") > 0 Then 'si la ligne de mon tableau virtuel contient la lettre "X"
        toto = Split(fichierCatia, "M")(1) 'alors la variable toto est égale à tout ce qui se trouve devant X
        toto = Left(toto, 6)
        toto = Replace(toto, "_", " ")
        Me.ListBox1.AddItem "VIS CHC M" & toto
        End If
        Me.ListBox1.ColumnCount = 1
        Me.ListBox1.ColumnWidths = "100"
        'Me.ListBox1.AddItem "VIS CHC M" & toto
        fichierCatia = Dir
    Loop
End If
'==
'== ci-dessous pour Chc M16
If ComboBox1.Value = "M16" And OptionButton2.Value = True Then
ListBox1.Clear
    repertoire = "\\Liens vers vos bibliohèque de vis\"
    fichierCatia = Dir(repertoire & "*M16*")
    Do While fichierCatia <> ""
    ListBox2.AddItem fichierCatia
        If InStr(fichierCatia, "M") > 0 Then 'si la ligne de mon tableau virtuel contient la lettre "X"
        toto = Split(fichierCatia, "M")(1) 'alors la variable toto est égale à tout ce qui se trouve devant X
        toto = Left(toto, 6)
        toto = Replace(toto, "_", " ")
        Me.ListBox1.AddItem "VIS CHC M" & toto
        End If
        Me.ListBox1.ColumnCount = 1
        Me.ListBox1.ColumnWidths = "100"
        'Me.ListBox1.AddItem "VIS CHC M" & toto
        fichierCatia = Dir
    Loop
End If
'==
'== ci-dessous pour Chc M20
If ComboBox1.Value = "M20" And OptionButton2.Value = True Then
ListBox1.Clear
    repertoire = "\\Liens vers vos bibliohèque de vis\"
    fichierCatia = Dir(repertoire & "*M20*")
    Do While fichierCatia <> ""
    ListBox2.AddItem fichierCatia
        If InStr(fichierCatia, "M") > 0 Then 'si la ligne de mon tableau virtuel contient la lettre "X"
        toto = Split(fichierCatia, "M")(1) 'alors la variable toto est égale à tout ce qui se trouve devant X
        toto = Left(toto, 6)
        toto = Replace(toto, "_", " ")
        Me.ListBox1.AddItem "VIS CHC M" & toto
        End If
        Me.ListBox1.ColumnCount = 1
        Me.ListBox1.ColumnWidths = "100"
        'Me.ListBox1.AddItem "VIS CHC M" & toto
        fichierCatia = Dir
    Loop
End If
'==
If ComboBox1.Value = "M3" Then
ComboBox2.AddItem "5"
ComboBox2.AddItem "6"
ComboBox2.AddItem "8"
ComboBox2.AddItem "10"
ComboBox2.AddItem "12"
ComboBox2.AddItem "16"
ComboBox2.AddItem "20"
ComboBox2.AddItem "25"
ComboBox2.AddItem "30"
End If
If ComboBox1.Value = "M4" Then
ComboBox2.AddItem "6"
ComboBox2.AddItem "8"
ComboBox2.AddItem "10"
ComboBox2.AddItem "12"
ComboBox2.AddItem "16"
ComboBox2.AddItem "20"
ComboBox2.AddItem "25"
ComboBox2.AddItem "30"
ComboBox2.AddItem "35"
ComboBox2.AddItem "40"
End If
If ComboBox1.Value = "M5" Then
ComboBox2.AddItem "8"
ComboBox2.AddItem "10"
ComboBox2.AddItem "12"
ComboBox2.AddItem "16"
ComboBox2.AddItem "20"
ComboBox2.AddItem "25"
ComboBox2.AddItem "30"
ComboBox2.AddItem "35"
ComboBox2.AddItem "40"
ComboBox2.AddItem "45"
ComboBox2.AddItem "50"
End If
If ComboBox1.Value = "M6" Then
ComboBox2.AddItem "10"
ComboBox2.AddItem "12"
ComboBox2.AddItem "16"
ComboBox2.AddItem "20"
ComboBox2.AddItem "25"
ComboBox2.AddItem "30"
ComboBox2.AddItem "35"
ComboBox2.AddItem "40"
ComboBox2.AddItem "45"
ComboBox2.AddItem "50"
ComboBox2.AddItem "55"
ComboBox2.AddItem "60"
End If
If ComboBox1.Value = "M8" Then
ComboBox2.AddItem "12"
ComboBox2.AddItem "16"
ComboBox2.AddItem "20"
ComboBox2.AddItem "25"
ComboBox2.AddItem "30"
ComboBox2.AddItem "35"
ComboBox2.AddItem "40"
ComboBox2.AddItem "45"
ComboBox2.AddItem "50"
ComboBox2.AddItem "55"
ComboBox2.AddItem "60"
ComboBox2.AddItem "65"
ComboBox2.AddItem "70"
ComboBox2.AddItem "80"
End If
If ComboBox1.Value = "M10" Then
ComboBox2.AddItem "16"
ComboBox2.AddItem "20"
ComboBox2.AddItem "25"
ComboBox2.AddItem "30"
ComboBox2.AddItem "35"
ComboBox2.AddItem "40"
ComboBox2.AddItem "45"
ComboBox2.AddItem "50"
ComboBox2.AddItem "55"
ComboBox2.AddItem "60"
ComboBox2.AddItem "65"
ComboBox2.AddItem "70"
ComboBox2.AddItem "80"
ComboBox2.AddItem "90"
ComboBox2.AddItem "100"
End If
If ComboBox1.Value = "M12" Then
ComboBox2.AddItem "20"
ComboBox2.AddItem "25"
ComboBox2.AddItem "30"
ComboBox2.AddItem "35"
ComboBox2.AddItem "40"
ComboBox2.AddItem "45"
ComboBox2.AddItem "50"
ComboBox2.AddItem "55"
ComboBox2.AddItem "60"
ComboBox2.AddItem "65"
ComboBox2.AddItem "70"
ComboBox2.AddItem "80"
ComboBox2.AddItem "90"
ComboBox2.AddItem "100"
ComboBox2.AddItem "110"
ComboBox2.AddItem "120"
End If
If ComboBox1.Value = "M16" Then
ComboBox2.AddItem "25"
ComboBox2.AddItem "30"
ComboBox2.AddItem "35"
ComboBox2.AddItem "40"
ComboBox2.AddItem "45"
ComboBox2.AddItem "50"
ComboBox2.AddItem "55"
ComboBox2.AddItem "60"
ComboBox2.AddItem "65"
ComboBox2.AddItem "70"
ComboBox2.AddItem "80"
ComboBox2.AddItem "90"
ComboBox2.AddItem "100"
ComboBox2.AddItem "110"
ComboBox2.AddItem "120"
ComboBox2.AddItem "130"
ComboBox2.AddItem "140"
ComboBox2.AddItem "150"
ComboBox2.AddItem "160"
End If
If ComboBox1.Value = "M20" Then
ComboBox2.AddItem "30"
ComboBox2.AddItem "35"
ComboBox2.AddItem "40"
ComboBox2.AddItem "45"
ComboBox2.AddItem "50"
ComboBox2.AddItem "55"
ComboBox2.AddItem "60"
ComboBox2.AddItem "65"
ComboBox2.AddItem "70"
ComboBox2.AddItem "80"
ComboBox2.AddItem "90"
ComboBox2.AddItem "100"
ComboBox2.AddItem "110"
ComboBox2.AddItem "120"
ComboBox2.AddItem "130"
ComboBox2.AddItem "140"
ComboBox2.AddItem "150"
ComboBox2.AddItem "160"
ComboBox2.AddItem "180"
ComboBox2.AddItem "200"
End If

End Sub

Public Sub CommandButton1_Click()
Dim productDocument1 As ProductDocument
Set productDocument1 = CATIA.ActiveDocument

Dim product1 As Product
Set product1 = productDocument1.Product

Dim MySelection As Object
Set MySelection = productDocument1.Selection

MySelection.Clear

Dim InputObjectType(0) As Variant
InputObjectType(0) = "Face"

'make a selection
Dim Result As String
Result = MySelection.SelectElement2(InputObjectType(), "Sélectionner l'axe", False)

'display brep path of face
Dim resName As String
resName = MySelection.Item(1).Value.DisplayName
'MsgBox resName

'locate part of face
Dim thePart As Product
Set thePart = MySelection.FindObject("CATIAProduct")

'display name of part
Dim partName As String
partName = thePart.Name
'MsgBox partName

'find the assembly the part belongs to
Dim myParent As Product
Set myParent = thePart.Parent

'display name of assembly
Dim assyName As String
assyName = myParent.Name
MsgBox assyName

'puts all together to form whole path of face
Dim refName As String
refName = assyName & "/" & partName & "/" & "!Axis:(" & resName & ")"
MsgBox refName
'Dim reference1 As Reference
Dim reference1 'As String
Set reference1 = product1.CreateReferenceFromName(refName)

'Set MaVisPub = MaVis.Publications.Item("Axis")
Set MaVisRef = MaVis.Publications.Item("Axis").Valuation

Dim constraints1 As Constraints
'Set constraints1 = product1.Connections("CATIAConstraints")
Set constraints1 = myParent.Connections("CATIAConstraints")
Dim constraint1 As Constraint
Set constraint1 = constraints1.AddBiEltCst(catCstTypeOn, MaVisRef, reference1)

product1.Update

End Sub

Private Sub CommandButton3_Click()
Dim oSel As Object
Set oSel = CATIA.ActiveDocument.Selection
Dim Filter(0)
Filter(0) = "Face"
Dim Result As String
Result = oSel.SelectElement2(Filter, " Select Body in which you want to add", False)
'Result = "Product2/25-10302-0000.1/!Axis:(" & oSel.Item(1).Value.Name & ")"
MsgBox Result
Dim bibi As String


For i = 1 To oSel.Count
bibi = oSel.Item(i).Value.Name
MsgBox bibi
Next




End Sub

Public Sub CommandButton5_Click()

Dim productDocument1 As ProductDocument
Set productDocument1 = CATIA.ActiveDocument

Dim product1 As Product
Set product1 = productDocument1.Product

Dim products1 As Products
Set products1 = product1.Products
Dim arrayOfVariantOfBSTR1(0)
arrayOfVariantOfBSTR1(0) = "\\Liens vers vos bibliohèque de vis\" & ListBox2.List(ListBox2.ListIndex, 0)

Dim Sel1 As Object
Dim Filter1(0)
Dim Status1 As String
Dim objPrd As Object
Dim fullpath 'As Object



Set Sel1 = CATIA.ActiveDocument.Selection
Filter1(0) = "Product"
Status1 = Sel1.SelectElement2(Filter1, "Sélectionner le product", False)

Set objPrd = Sel1.Item2(1).LeafProduct
fullpath = objPrd.Name

If Not InStr(fullpath, "roduct") > 0 Then
    MsgBox "vous n'avez pas sélectionné un product"
    Exit Sub
End If

Dim products2 As Products
Set products2 = objPrd
Set fullpath = products2

fullpath.AddComponentsFromFiles arrayOfVariantOfBSTR1, "All"
For i = 1 To products2.Count
Dim bibi As String
'Dim MaVis As Product
Set MaVis = products2.Item(i)
Next
MaVis.ApplyWorkMode DESIGN_MODE
TextBox2.Value = MaVis.Name
Sel1.Clear
'Sel1.Add toto

'Dim MaVis As Product
'Set MaVis = objpart.LeafProduct

Set MaVisPub = MaVis.Publications.Item("Axis")
Set MaVisRef = MaVisPub.Valuation
Sel1.Add MaVisRef

End Sub

Private Sub Label4_Click()

End Sub

Private Sub ListBox1_Click()
ListBox2.ListIndex = ListBox1.ListIndex
fichierCAT = ListBox2.List(ListBox2.ListIndex, 0) 'mon fichier catia est celui que j'ai sélectionné dans la listbox
TextBox1.Value = Round(FileLen("\\Liens vers vos bibliohèque de vis\" & fichierCAT) / 1000, 1) 'je calcul le poids du fichier en ko

If TextBox1.Value < 500 Then 'si le fichier fait moins de 500 Ko alors je charge son image via le code ci-dessous
Dim OBJstream, BB() As Byte, ok As Boolean, i As Long, f As Long, fini As Long
    Set OBJstream = CreateObject("ADODB.Stream")    'object utilisé ADODB stream
    OBJstream.Open: OBJstream.Type = 1    ' open with no arguments makes the stream an empty container
    OBJstream.LoadFromFile ("\\Liens vers vos bibliohèque de vis\" & fichierCAT)    'on load le fichier dans l'object
    BB = OBJstream.Read()    ' on prend directement tout le paquet
    fin = UBound(BB) - 1
    f = UBound(BB) - 1
    '**************************************
    jpegFile = FreeFile
    Open "C:\TEMP\image.jpg" For Binary Access Write Lock Write As jpegFile
    For i = 0 To fin
        If fini = 0 Then
            If BB(f) = 255 And BB(f + 1) = 217 Then fini = f + 2: Debug.Print f & " -- " & fin ' dans le debug on vois la différence de fin et la vrai fin
        End If
        f = f - 1
        If BB(i) = 255 And BB(i + 1) = 216 Then ok = True
        If ok = True Then Put jpegFile, , BB(i)
        If i = fini And i > 0 Then Exit For
    Next
    Close jpegFile
On Error Resume Next
Image2.Picture = LoadPicture("C:\TEMP\image.jpg")

End If
End Sub

Private Sub OptionButton2_Click()
On Error Resume Next
Image1.Picture = LoadPicture("\\Liens vers vos bibliohèque de vis\")
Dim toto As String
Dim repertoire As String, fichierCatia As String
ListBox2.Clear
ComboBox2.Clear
If ComboBox1.Value = "M2.5" Then
ComboBox2.AddItem "4"
ComboBox2.AddItem "5"
ComboBox2.AddItem "6"
ComboBox2.AddItem "8"
ComboBox2.AddItem "10"
ComboBox2.AddItem "12"
ComboBox2.AddItem "16"
ComboBox2.AddItem "20"
ComboBox2.AddItem "25"
End If
'== ci-dessous pour Chc M3
If ComboBox1.Value = "M3" And OptionButton2.Value = True Then
ListBox1.Clear
    repertoire = "\\Liens vers vos bibliohèque de vis\"
    fichierCatia = Dir(repertoire & "*M3*")
    Do While fichierCatia <> ""
    ListBox2.AddItem fichierCatia
        If InStr(fichierCatia, "M") > 0 Then 'si la ligne de mon tableau virtuel contient la lettre "M"
        toto = Split(fichierCatia, "M")(1) 'alors la variable toto est égale à tout ce qui se trouve devant M
        toto = Left(toto, 4)
        toto = Replace(toto, "_", " ")
        Me.ListBox1.AddItem "VIS CHC M" & toto
        End If
        Me.ListBox1.ColumnCount = 1
        Me.ListBox1.ColumnWidths = "100"
        'Me.ListBox1.AddItem "VIS CHC M" & toto
        fichierCatia = Dir
    Loop
End If
'==
'== ci-dessous pour Chc M4
If ComboBox1.Value = "M4" And OptionButton2.Value = True Then
ListBox1.Clear
    repertoire = "\\Liens vers vos bibliohèque de vis\"
    fichierCatia = Dir(repertoire & "*M4*")
    Do While fichierCatia <> ""
    ListBox2.AddItem fichierCatia
        If InStr(fichierCatia, "M") > 0 Then 'si la ligne de mon tableau virtuel contient la lettre "X"
        toto = Split(fichierCatia, "M")(1) 'alors la variable toto est égale à tout ce qui se trouve devant X
        toto = Left(toto, 4)
        toto = Replace(toto, "_", " ")
        Me.ListBox1.AddItem "VIS CHC M" & toto
        End If
        Me.ListBox1.ColumnCount = 1
        Me.ListBox1.ColumnWidths = "100"
        'Me.ListBox1.AddItem "VIS CHC M" & toto
        fichierCatia = Dir
    Loop
End If
'==
'== ci-dessous pour Chc M5
If ComboBox1.Value = "M5" And OptionButton2.Value = True Then
ListBox1.Clear
    repertoire = "\\Liens vers vos bibliohèque de vis\"
    fichierCatia = Dir(repertoire & "*M5*")
    Do While fichierCatia <> ""
    ListBox2.AddItem fichierCatia
        If InStr(fichierCatia, "M") > 0 Then 'si la ligne de mon tableau virtuel contient la lettre "X"
        toto = Split(fichierCatia, "M")(1) 'alors la variable toto est égale à tout ce qui se trouve devant X
        toto = Left(toto, 5)
        toto = Replace(toto, "_", " ")
        Me.ListBox1.AddItem "VIS CHC M" & toto
        End If
        Me.ListBox1.ColumnCount = 1
        Me.ListBox1.ColumnWidths = "100"
        'Me.ListBox1.AddItem "VIS CHC M" & toto
        fichierCatia = Dir
    Loop
End If
'==
'== ci-dessous pour Chc M6
If ComboBox1.Value = "M6" And OptionButton2.Value = True Then
ListBox1.Clear
    repertoire = "\\Liens vers vos bibliohèque de vis\"
    fichierCatia = Dir(repertoire & "*M6*")
    Do While fichierCatia <> ""
    ListBox2.AddItem fichierCatia
        If InStr(fichierCatia, "M") > 0 Then 'si la ligne de mon tableau virtuel contient la lettre "X"
        toto = Split(fichierCatia, "M")(1) 'alors la variable toto est égale à tout ce qui se trouve devant X
        toto = Left(toto, 5)
        toto = Replace(toto, "_", " ")
        Me.ListBox1.AddItem "VIS CHC M" & toto
        End If
        Me.ListBox1.ColumnCount = 1
        Me.ListBox1.ColumnWidths = "100"
        'Me.ListBox1.AddItem "VIS CHC M" & toto
        fichierCatia = Dir
    Loop
End If
'==
'== ci-dessous pour Chc M8
If ComboBox1.Value = "M8" And OptionButton2.Value = True Then
ListBox1.Clear
    repertoire = "\\Liens vers vos bibliohèque de vis\"
    fichierCatia = Dir(repertoire & "*M8*")
    Do While fichierCatia <> ""
    ListBox2.AddItem fichierCatia
        If InStr(fichierCatia, "M") > 0 Then 'si la ligne de mon tableau virtuel contient la lettre "X"
        toto = Split(fichierCatia, "M")(1) 'alors la variable toto est égale à tout ce qui se trouve devant X
        toto = Left(toto, 5)
        toto = Replace(toto, "_", " ")
        Me.ListBox1.AddItem "VIS CHC M" & toto
        End If
        Me.ListBox1.ColumnCount = 1
        Me.ListBox1.ColumnWidths = "100"
        'Me.ListBox1.AddItem "VIS CHC M" & toto
        fichierCatia = Dir
    Loop
End If
'==
'== ci-dessous pour Chc M10
If ComboBox1.Value = "M10" And OptionButton2.Value = True Then
ListBox1.Clear
    repertoire = "\\Liens vers vos bibliohèque de vis\"
    fichierCatia = Dir(repertoire & "*M10*")
    Do While fichierCatia <> ""
    ListBox2.AddItem fichierCatia
        If InStr(fichierCatia, "M") > 0 Then 'si la ligne de mon tableau virtuel contient la lettre "X"
        toto = Split(fichierCatia, "M")(1) 'alors la variable toto est égale à tout ce qui se trouve devant X
        toto = Left(toto, 6)
        toto = Replace(toto, "_", " ")
        Me.ListBox1.AddItem "VIS CHC M" & toto
        End If
        Me.ListBox1.ColumnCount = 1
        Me.ListBox1.ColumnWidths = "100"
        'Me.ListBox1.AddItem "VIS CHC M" & toto
        fichierCatia = Dir
    Loop
End If
'==
'== ci-dessous pour Chc M12
If ComboBox1.Value = "M12" And OptionButton2.Value = True Then
ListBox1.Clear
    repertoire = "\\Liens vers vos bibliohèque de vis\"
    fichierCatia = Dir(repertoire & "*M12*")
    Do While fichierCatia <> ""
    ListBox2.AddItem fichierCatia
        If InStr(fichierCatia, "M") > 0 Then 'si la ligne de mon tableau virtuel contient la lettre "X"
        toto = Split(fichierCatia, "M")(1) 'alors la variable toto est égale à tout ce qui se trouve devant X
        toto = Left(toto, 6)
        toto = Replace(toto, "_", " ")
        Me.ListBox1.AddItem "VIS CHC M" & toto
        End If
        Me.ListBox1.ColumnCount = 1
        Me.ListBox1.ColumnWidths = "100"
        'Me.ListBox1.AddItem "VIS CHC M" & toto
        fichierCatia = Dir
    Loop
End If
'==
'== ci-dessous pour Chc M14
If ComboBox1.Value = "M14" And OptionButton2.Value = True Then
ListBox1.Clear
    repertoire = "\\Liens vers vos bibliohèque de vis\"
    fichierCatia = Dir(repertoire & "*M14*")
    Do While fichierCatia <> ""
    ListBox2.AddItem fichierCatia
        If InStr(fichierCatia, "M") > 0 Then 'si la ligne de mon tableau virtuel contient la lettre "X"
        toto = Split(fichierCatia, "M")(1) 'alors la variable toto est égale à tout ce qui se trouve devant X
        toto = Left(toto, 6)
        toto = Replace(toto, "_", " ")
        Me.ListBox1.AddItem "VIS CHC M" & toto
        End If
        Me.ListBox1.ColumnCount = 1
        Me.ListBox1.ColumnWidths = "100"
        'Me.ListBox1.AddItem "VIS CHC M" & toto
        fichierCatia = Dir
    Loop
End If
'==
'== ci-dessous pour Chc M16
If ComboBox1.Value = "M16" And OptionButton2.Value = True Then
ListBox1.Clear
    repertoire = "\\Liens vers vos bibliohèque de vis\"
    fichierCatia = Dir(repertoire & "*M16*")
    Do While fichierCatia <> ""
    ListBox2.AddItem fichierCatia
        If InStr(fichierCatia, "M") > 0 Then 'si la ligne de mon tableau virtuel contient la lettre "X"
        toto = Split(fichierCatia, "M")(1) 'alors la variable toto est égale à tout ce qui se trouve devant X
        toto = Left(toto, 6)
        toto = Replace(toto, "_", " ")
        Me.ListBox1.AddItem "VIS CHC M" & toto
        End If
        Me.ListBox1.ColumnCount = 1
        Me.ListBox1.ColumnWidths = "100"
        'Me.ListBox1.AddItem "VIS CHC M" & toto
        fichierCatia = Dir
    Loop
End If
'==
'== ci-dessous pour Chc M20
If ComboBox1.Value = "M20" And OptionButton2.Value = True Then
ListBox1.Clear
    repertoire = "\\Liens vers vos bibliohèque de vis\"
    fichierCatia = Dir(repertoire & "*M20*")
    Do While fichierCatia <> ""
    ListBox2.AddItem fichierCatia
        If InStr(fichierCatia, "M") > 0 Then 'si la ligne de mon tableau virtuel contient la lettre "X"
        toto = Split(fichierCatia, "M")(1) 'alors la variable toto est égale à tout ce qui se trouve devant X
        toto = Left(toto, 6)
        toto = Replace(toto, "_", " ")
        Me.ListBox1.AddItem "VIS CHC M" & toto
        End If
        Me.ListBox1.ColumnCount = 1
        Me.ListBox1.ColumnWidths = "100"
        'Me.ListBox1.AddItem "VIS CHC M" & toto
        fichierCatia = Dir
    Loop
End If
'==
If ComboBox1.Value = "M3" Then
ComboBox2.AddItem "5"
ComboBox2.AddItem "6"
ComboBox2.AddItem "8"
ComboBox2.AddItem "10"
ComboBox2.AddItem "12"
ComboBox2.AddItem "16"
ComboBox2.AddItem "20"
ComboBox2.AddItem "25"
ComboBox2.AddItem "30"
End If
If ComboBox1.Value = "M4" Then
ComboBox2.AddItem "6"
ComboBox2.AddItem "8"
ComboBox2.AddItem "10"
ComboBox2.AddItem "12"
ComboBox2.AddItem "16"
ComboBox2.AddItem "20"
ComboBox2.AddItem "25"
ComboBox2.AddItem "30"
ComboBox2.AddItem "35"
ComboBox2.AddItem "40"
End If
If ComboBox1.Value = "M5" Then
ComboBox2.AddItem "8"
ComboBox2.AddItem "10"
ComboBox2.AddItem "12"
ComboBox2.AddItem "16"
ComboBox2.AddItem "20"
ComboBox2.AddItem "25"
ComboBox2.AddItem "30"
ComboBox2.AddItem "35"
ComboBox2.AddItem "40"
ComboBox2.AddItem "45"
ComboBox2.AddItem "50"
End If
If ComboBox1.Value = "M6" Then
ComboBox2.AddItem "10"
ComboBox2.AddItem "12"
ComboBox2.AddItem "16"
ComboBox2.AddItem "20"
ComboBox2.AddItem "25"
ComboBox2.AddItem "30"
ComboBox2.AddItem "35"
ComboBox2.AddItem "40"
ComboBox2.AddItem "45"
ComboBox2.AddItem "50"
ComboBox2.AddItem "55"
ComboBox2.AddItem "60"
End If
If ComboBox1.Value = "M8" Then
ComboBox2.AddItem "12"
ComboBox2.AddItem "16"
ComboBox2.AddItem "20"
ComboBox2.AddItem "25"
ComboBox2.AddItem "30"
ComboBox2.AddItem "35"
ComboBox2.AddItem "40"
ComboBox2.AddItem "45"
ComboBox2.AddItem "50"
ComboBox2.AddItem "55"
ComboBox2.AddItem "60"
ComboBox2.AddItem "65"
ComboBox2.AddItem "70"
ComboBox2.AddItem "80"
End If
If ComboBox1.Value = "M10" Then
ComboBox2.AddItem "16"
ComboBox2.AddItem "20"
ComboBox2.AddItem "25"
ComboBox2.AddItem "30"
ComboBox2.AddItem "35"
ComboBox2.AddItem "40"
ComboBox2.AddItem "45"
ComboBox2.AddItem "50"
ComboBox2.AddItem "55"
ComboBox2.AddItem "60"
ComboBox2.AddItem "65"
ComboBox2.AddItem "70"
ComboBox2.AddItem "80"
ComboBox2.AddItem "90"
ComboBox2.AddItem "100"
End If
If ComboBox1.Value = "M12" Then
ComboBox2.AddItem "20"
ComboBox2.AddItem "25"
ComboBox2.AddItem "30"
ComboBox2.AddItem "35"
ComboBox2.AddItem "40"
ComboBox2.AddItem "45"
ComboBox2.AddItem "50"
ComboBox2.AddItem "55"
ComboBox2.AddItem "60"
ComboBox2.AddItem "65"
ComboBox2.AddItem "70"
ComboBox2.AddItem "80"
ComboBox2.AddItem "90"
ComboBox2.AddItem "100"
ComboBox2.AddItem "110"
ComboBox2.AddItem "120"
End If
If ComboBox1.Value = "M16" Then
ComboBox2.AddItem "25"
ComboBox2.AddItem "30"
ComboBox2.AddItem "35"
ComboBox2.AddItem "40"
ComboBox2.AddItem "45"
ComboBox2.AddItem "50"
ComboBox2.AddItem "55"
ComboBox2.AddItem "60"
ComboBox2.AddItem "65"
ComboBox2.AddItem "70"
ComboBox2.AddItem "80"
ComboBox2.AddItem "90"
ComboBox2.AddItem "100"
ComboBox2.AddItem "110"
ComboBox2.AddItem "120"
ComboBox2.AddItem "130"
ComboBox2.AddItem "140"
ComboBox2.AddItem "150"
ComboBox2.AddItem "160"
End If
If ComboBox1.Value = "M20" Then
ComboBox2.AddItem "30"
ComboBox2.AddItem "35"
ComboBox2.AddItem "40"
ComboBox2.AddItem "45"
ComboBox2.AddItem "50"
ComboBox2.AddItem "55"
ComboBox2.AddItem "60"
ComboBox2.AddItem "65"
ComboBox2.AddItem "70"
ComboBox2.AddItem "80"
ComboBox2.AddItem "90"
ComboBox2.AddItem "100"
ComboBox2.AddItem "110"
ComboBox2.AddItem "120"
ComboBox2.AddItem "130"
ComboBox2.AddItem "140"
ComboBox2.AddItem "150"
ComboBox2.AddItem "160"
ComboBox2.AddItem "180"
ComboBox2.AddItem "200"
End If
End Sub

Private Sub OptionButton3_Click()

End Sub

Private Sub UserForm_Initialize()

'ComboBox1.AddItem "M2.5"
ComboBox1.AddItem "M3"
ComboBox1.AddItem "M4"
ComboBox1.AddItem "M5"
ComboBox1.AddItem "M6"
ComboBox1.AddItem "M8"
ComboBox1.AddItem "M10"
ComboBox1.AddItem "M12"
ComboBox1.AddItem "M16"
'ComboBox1.AddItem "M18"
ComboBox1.AddItem "M20"

End Sub

si ça peut vous servir de base, je n'ai malheureusement pas plus de temps pour m'y consacrer.
le code est largement perfectible.
pensez à bien remplacer les différents répertoires par ceux contenant vos vis.

Flo

Flo42
timide
timide

Messages : 19
Date d'inscription : 22/04/2021
Localisation : Saint-Etienne

Revenir en haut Aller en bas

Ajout automatique de visserie Empty Re: Ajout automatique de visserie

Message par Liocco08 Jeu 21 Mar 2024 - 9:54

Salut Marc,

Alors chez nous, on bosse pour les gros de l'aéro sur Toulouse et ça va dépendre du client...globalement nos constructeurs de rafales et de jet privés ont un dossier contenant à peu près toute la visserie (vis, écrou, rondelle, goupille, insert etc...).

Voici des noms types :

https://i.servimg.com/u/f70/20/41/86/18/captur17.jpg

Quasi sûr que ça vient de la bibliothèque de visserie initiale de CATIA qu'ils ont enrichis et adapté à leur sauce. L'avantage étant qu'ils ont déjà fais ce travail de publier systématiquement l'axe ainsi que la face d'appui utile pour les vis, rondelles et écrou. (D'ailleurs tu saurais m'expliquer l'intérêt des publications ? Je n'ai jamais réellement compris l'intérêt par rapport à contraindre classiquement avec l'axe formé par la pièce de révolution ?).

Après j'ai jamais compris pourquoi certaines part était enregistrée avec l'extension "CATPart" et d'autres "CATpart"...

https://i.servimg.com/u/f70/20/41/86/18/captur19.jpg

Bon c'est quand même en énorme sujet, ça va être dur de trouver du temps pour ça ^^


Liocco08
actif
actif

Messages : 39
Date d'inscription : 07/04/2022
Localisation : Toulouse

Revenir en haut Aller en bas

Ajout automatique de visserie Empty Re: Ajout automatique de visserie

Message par Liocco08 Jeu 21 Mar 2024 - 9:57

Bonjour Flo42,

Merci pour ton message ça peut effectivement être une excellente base pour commencer ! Comme tu le dis c'est un sujet qui prends beaucoup de temps et je te ferai signe si j'ai pu avancer sur le sujet.

De mémoire elle était fonctionnelle ta macro ?

Merci !

Liocco08
actif
actif

Messages : 39
Date d'inscription : 07/04/2022
Localisation : Toulouse

Revenir en haut Aller en bas

Ajout automatique de visserie Empty Re: Ajout automatique de visserie

Message par Flo42 Ven 22 Mar 2024 - 11:46

Bonjour,

Oui elle fonctionnait mais je trouvais qu'elle manquait de "peps".

Bon courage

Flo

Flo42
timide
timide

Messages : 19
Date d'inscription : 22/04/2021
Localisation : Saint-Etienne

Revenir en haut Aller en bas

Ajout automatique de visserie Empty Re: Ajout automatique de visserie

Message par Contenu sponsorisé


Contenu sponsorisé


Revenir en haut Aller en bas

Revenir en haut

- Sujets similaires

 
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum