1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
| Sub ExtraireCartouche()
Dim cartouche As AcadBlockReference
Dim obj As AcadEntity
Dim dbplan As Object
Dim plan As Recordset
Dim sset As Object
Dim attributeObj As AcadAttribute
Dim varAttributes As Variant
Dim strAttributes, projet As String
Dim proy As Boolean
Dim req As String
Dim i, ligne, j, k, colonne As Integer
Dim indice(0 To 4, 0 To 5)
Dim lettre, champ As Variant
'Création de ma liste de valeur
Set sset = ThisDrawing.SelectionSets.Add("SS3")
' Prompt the user to select objects
sset.SelectOnScreen
For Each obj In sset
Set cartouche = obj
Next
varAttributes = cartouche.GetAttributes
lettre = Array("A", "B", "C", "D", "E", "F")
champ = Array("fecha", "puest", "autor", "contr")
proy = False
plan.AddNew
For i = LBound(varAttributes) To UBound(varAttributes)
MsgBox "nom de l'attribut : " & varAttributes(i).TagString
'remplissage du tableau "indice" avec les valeurs des champs d'indice
'en cherchant à quelle coordonnée (ligne, colonne)
'ils doivent se trouver dans le tableau
For j = 0 To 5
If Right(varAttributes(i).TagString, 1) = lettre(j) Then
'si l'étiquette de l'attribut est de longueur 1,
'alors on est à la première ligne du tableau "indice",
'qui contient la valeur de l'indice
MsgBox "boucle : lettre " & Right(varAttributes(i).TagString, 1) & " J = " & j
If Len(varAttributes(i).TagString) = 1 Then
ligne = 0
colonne = j
MsgBox "indice " & lettre(j)
'sinon on cherche dans le tableau champ la valeur de la colonne
Else
For k = 0 To 3
If Left(varAttributes(i).TagString, 5) = champ(k) Then
ligne = k + 1
colonne = j
End If
Next
k = 0
End If
End If
Next
j = 0
If colonne <> "" And ligne <> "" Then
indice(ligne, colonne) = varAttributes(i).TextString
MsgBox ("placement de " & varAttributes(i).TextString & " à la ligne " & ligne & " et à la colonne " & colonne)
End If
affichtab (indice)
ThisDrawing.SelectionSets("SS3").Delete
End Sub |
Partager