douaa2004
Messages postés12Date d'inscriptionjeudi 4 juin 2009StatutMembreDernière intervention29 octobre 2009
-
28 oct. 2009 à 18:08
douaa2004
Messages postés12Date d'inscriptionjeudi 4 juin 2009StatutMembreDernière intervention29 octobre 2009
-
29 oct. 2009 à 11:39
salut,
svp j'ai besoin de votre aide sur un programme voilà j'essaye de selectionner des blocs et en extraire des attribut avec VBA sous autocad2004 mais ça ne marche pas je ne sais pas ou est le problème?
voilà mon code svp :
Sub Extraction()
Dim rangee As Integer
Dim matrice As Variant
Dim compte As Integer
Dim selection As AcadSelectionSet
' ---------------------------------------------------
'Section 4. Sélection du bloc spécifié.
' ---------------------------------------------------
Dim EnTete As Boolean
rangee = 1
EnTete = False
If selection_existe("TEMP") Then
Set selection = ThisDrawing.SelectionSets("TEMP")
selection.Clear
Else
Set selection = ThisDrawing.SelectionSets.Add("TEMP")
End If
' ---------------------------------------------------
'Section 4. Extraction des attributs.
' Le premier bloc fournit les noms d'attributs (TAG)
' ---------------------------------------------------
Dim Entite As AcadBlockReference
For Each Entite In selection
matrice = Entite.GetAttributes
If EnTete = False Then
For compte = LBound(matrice) To UBound(matrice)
If StrComp(matrice(compte).EntityName, "AcDbAttribute", 1) = 0 Then
Feuille.Cells(rangee, compte + 1).Value = matrice(compte).TagString
End If
Next compte
End If
rangee = rangee + 1
For compte = LBound(matrice) To UBound(matrice)
Feuille.Cells(rangee, compte + 1).Value = matrice(compte).TextString
Next compte
EnTete = True
Next
End Sub
' ---------------------------------------------------
'Section 6. effacer la selection "TEMP"
' ---------------------------------------------------
Public Function selection_existe(strnom As String) As Boolean
Dim control As Boolean
control = False
On Error Resume Next
Set objselection = ThisDrawing.SelectionSets(strnom)
If Err Then
Err.Clear
Set objselection = ThisDrawing.SelectionSets.Add(strnom)
If Not Err Then control = True
Else
control = True
End If
selection_existe = control
End Function
pile_poil
Messages postés682Date d'inscriptionvendredi 6 avril 2007StatutMembreDernière intervention 4 août 20126 29 oct. 2009 à 06:54
Tu as dans le répertoire d'autocad un sous répertoire sample
dedans tu as dans ActiveX "ExtAttr" qui est une excellent exemple de ce que tu recherches à faire et ceci en VBA Excel
maintenant si tu veux ta macro depuis autocad tu regardes dans le répertoire VBA le fichier ExcelLink.dvd qui fait l'export d'attributs de blocs vers excel et accessoirement le réImport apres modification des données
tu y trouveras notamment comment créer une référence à excel
chose qui manque dans ton bout de code