Accueil > > > NOMENCLATURES AUTOCAD VERS EXCEL
NOMENCLATURES AUTOCAD VERS EXCEL
Information sur la source
Description
Mon programme (en VBA AutoCAD) permet de transférer des nomenclatures autoCAD vers une feuille Excel, ce qui peut se revélé bien pratique. Explication : Pour créer des nomenclatures sous autoCAD créez d'abord pour chacune de vos pièces de plan un info-point (ou référence de pièce), celà alimente une nomenclature dans autoCAD. LA nomenclature est ainsi géré automatiquement par AutoCAD Cette nomenclature se met a jour à chaque modification de vos info point, et gere automatiquement les quentité de pièce,etc... Comment l'utiliser : Ouvrez Excel, et créez une nouvelle feuille. Enuite ouvrez un plan autoCAD avec des references de pièces, et lancez la macro. Il se peut que vous ayez à modifier la macro pour l'adapter à vos besoins !
Source
- '**************************************
- '* *
- '* EXPORT DE NOMENCLATURE AUTOCAD *
- '* VERS MICROSOFT EXCEL *
- '* *
- '* Ecrit par LEVEUGLE Damien (c) 2005 *
- '* *
- '**************************************
-
- Option Explicit
-
- Public Enum EXCELCOL
- IGNORE = 0
- REFERE = 1
- REPER = 2
- DESIGN = 4
- MATIERE = 5
- NUM_DE_PLAN = 7
- CODE_ARTICLE = 9
- MASSE = 10
- DESCR = 11
- End Enum
-
- Public Sub subExtracToXL()
-
- '****************
- '* DECLARATIONS *
- '****************
- Const REEL69SS = "REEL_PARTREFERENCE"
-
- Dim objExelApp As Excel.Application
- Dim objExelSheet As Excel.Worksheet
- Dim gpCode(0) As Integer
- Dim dataValue(0) As Variant
- Dim groupCode As Variant
- Dim dataCode As Variant
- Dim MySelectionSet As AcadSelectionSet
- Dim MyMPR As McadPartReference
- Dim I As Integer
- Dim LigneExcel As Integer
- Dim ColonneExcel As EXCELCOL
-
- '******************
- '* INITIALISATION *
- '******************
-
- On Error Resume Next ' Gestion erreurs
-
- ThisDrawing.SelectionSets(REEL69SS).Delete
- Set MySelectionSet = ThisDrawing.SelectionSets.Add(REEL69SS)
-
- gpCode(0) = 0
- dataValue(0) = "ACMPARTREF"
- groupCode = gpCode
- dataCode = dataValue
- LigneExcel = 9
- ColonneExcel = IGNORE
-
- '*************
- '* SELECTION *
- '*************
-
- ThisDrawing.SelectionSets(REEL69SS).Select acSelectionSetAll, , , groupCode, dataCode
- If ThisDrawing.SelectionSets(REEL69SS).Count = 0 Then
- MsgBox "Aucune pièce dans la nomenclature présente.", vbInformation, "Pas de pièces"
- Exit Sub
- End If
-
- Err.Clear
-
- '*********************
- '* APPLICATION EXCEL *
- '*********************
-
- Set objExelApp = GetObject(, "excel.application") ' ouvre le classeur courant
-
- If Err Then ' si excel non ouvert on en crée un !
- Err.Clear
- Set objExelApp = Nothing
- Set objExelApp = CreateObject("excel.application")
- If Err Then
- Err.Clear
- MsgBox "L'application Excel n'est pas présente sur votre poste", vbCritical, "EXCEL"
- Exit Sub
- End If
- End If
-
- objExelApp.Visible = True
-
- Set objExelSheet = objExelApp.ActiveSheet
-
- On Error GoTo 0
-
- '**********************************
- '* PLACE PIECE TROUVER DANS EXCEL *
- '**********************************
-
- For Each MyMPR In ThisDrawing.SelectionSets(REEL69SS) ' Parcoure chaque ligne de la NT
-
- If IsEmpty(MyMPR.Data) Then
- MsgBox "Nomenclature vide", vbInformation, "Vide"
- GoTo final
- Else
-
- LigneExcel = LigneExcel + 1 ' position dans excel
-
- objExelSheet.Cells(LigneExcel, 3).Value = MyMPR.Quantity
-
- For I = LBound(MyMPR.Data) To UBound(MyMPR.Data) ' Lit chaque champs de la ligne
-
- Select Case MyMPR.Data(I, 0)
- Case "REF": ColonneExcel = REFERE ' Associe les champs de nomenclature AutoCAD
- Case "REPERE": ColonneExcel = REPER ' aux colonnes d'Excel
- Case "NAME": ColonneExcel = DESIGN
- Case "MATERIAL": ColonneExcel = MATIERE
- Case "N°_DE_PLAN": ColonneExcel = NUM_DE_PLAN
- Case "CODE_ARTICLE": ColonneExcel = CODE_ARTICLE
- Case "MASS": ColonneExcel = MASSE
- Case "DESCR": ColonneExcel = DESCR
- Case Else
- ColonneExcel = IGNORE
- End Select
-
- If ColonneExcel <> IGNORE Then objExelSheet.Cells(LigneExcel, ColonneExcel).Value = MyMPR.Data(I, 1)
-
- Next I
-
- End If
-
- Next
-
- '*******************
- '* TRIE DANS EXCEL *
- '*******************
-
- objExelSheet.Range("B10:J600").Sort Key1:=objExelSheet.Columns("B"), Order1:=xlAscending, MatchCase:=False, Orientation:=xlTopToBottom
- objExelSheet.Range("A10").Select
-
- final:
-
- '*********************
- '* LIBERE LA MEMOIRE *
- '*********************
-
- Set objExelApp = Nothing
- Set objExelSheet = Nothing
- Set MySelectionSet = Nothing
-
- End Sub
'**************************************
'* *
'* EXPORT DE NOMENCLATURE AUTOCAD *
'* VERS MICROSOFT EXCEL *
'* *
'* Ecrit par LEVEUGLE Damien (c) 2005 *
'* *
'**************************************
Option Explicit
Public Enum EXCELCOL
IGNORE = 0
REFERE = 1
REPER = 2
DESIGN = 4
MATIERE = 5
NUM_DE_PLAN = 7
CODE_ARTICLE = 9
MASSE = 10
DESCR = 11
End Enum
Public Sub subExtracToXL()
'****************
'* DECLARATIONS *
'****************
Const REEL69SS = "REEL_PARTREFERENCE"
Dim objExelApp As Excel.Application
Dim objExelSheet As Excel.Worksheet
Dim gpCode(0) As Integer
Dim dataValue(0) As Variant
Dim groupCode As Variant
Dim dataCode As Variant
Dim MySelectionSet As AcadSelectionSet
Dim MyMPR As McadPartReference
Dim I As Integer
Dim LigneExcel As Integer
Dim ColonneExcel As EXCELCOL
'******************
'* INITIALISATION *
'******************
On Error Resume Next ' Gestion erreurs
ThisDrawing.SelectionSets(REEL69SS).Delete
Set MySelectionSet = ThisDrawing.SelectionSets.Add(REEL69SS)
gpCode(0) = 0
dataValue(0) = "ACMPARTREF"
groupCode = gpCode
dataCode = dataValue
LigneExcel = 9
ColonneExcel = IGNORE
'*************
'* SELECTION *
'*************
ThisDrawing.SelectionSets(REEL69SS).Select acSelectionSetAll, , , groupCode, dataCode
If ThisDrawing.SelectionSets(REEL69SS).Count = 0 Then
MsgBox "Aucune pièce dans la nomenclature présente.", vbInformation, "Pas de pièces"
Exit Sub
End If
Err.Clear
'*********************
'* APPLICATION EXCEL *
'*********************
Set objExelApp = GetObject(, "excel.application") ' ouvre le classeur courant
If Err Then ' si excel non ouvert on en crée un !
Err.Clear
Set objExelApp = Nothing
Set objExelApp = CreateObject("excel.application")
If Err Then
Err.Clear
MsgBox "L'application Excel n'est pas présente sur votre poste", vbCritical, "EXCEL"
Exit Sub
End If
End If
objExelApp.Visible = True
Set objExelSheet = objExelApp.ActiveSheet
On Error GoTo 0
'**********************************
'* PLACE PIECE TROUVER DANS EXCEL *
'**********************************
For Each MyMPR In ThisDrawing.SelectionSets(REEL69SS) ' Parcoure chaque ligne de la NT
If IsEmpty(MyMPR.Data) Then
MsgBox "Nomenclature vide", vbInformation, "Vide"
GoTo final
Else
LigneExcel = LigneExcel + 1 ' position dans excel
objExelSheet.Cells(LigneExcel, 3).Value = MyMPR.Quantity
For I = LBound(MyMPR.Data) To UBound(MyMPR.Data) ' Lit chaque champs de la ligne
Select Case MyMPR.Data(I, 0)
Case "REF": ColonneExcel = REFERE ' Associe les champs de nomenclature AutoCAD
Case "REPERE": ColonneExcel = REPER ' aux colonnes d'Excel
Case "NAME": ColonneExcel = DESIGN
Case "MATERIAL": ColonneExcel = MATIERE
Case "N°_DE_PLAN": ColonneExcel = NUM_DE_PLAN
Case "CODE_ARTICLE": ColonneExcel = CODE_ARTICLE
Case "MASS": ColonneExcel = MASSE
Case "DESCR": ColonneExcel = DESCR
Case Else
ColonneExcel = IGNORE
End Select
If ColonneExcel <> IGNORE Then objExelSheet.Cells(LigneExcel, ColonneExcel).Value = MyMPR.Data(I, 1)
Next I
End If
Next
'*******************
'* TRIE DANS EXCEL *
'*******************
objExelSheet.Range("B10:J600").Sort Key1:=objExelSheet.Columns("B"), Order1:=xlAscending, MatchCase:=False, Orientation:=xlTopToBottom
objExelSheet.Range("A10").Select
final:
'*********************
'* LIBERE LA MEMOIRE *
'*********************
Set objExelApp = Nothing
Set objExelSheet = Nothing
Set MySelectionSet = Nothing
End Sub
Conclusion
J'ai trimé pour trouver comment faire, et je n'ai trouvé aucune source sur le net ni même de documentation pour l'utilisation des nomenclatures sous AutoCAD, donc si c'est mal codé priere de m'escuser.
Sinon je suis preneur pour les vos améliorations et vos insultes (lol)
NB : Des fois VBA vous renvoi des erreurs, ceci peut être du à des references (librairies) non coché !
Sources du même auteur
Sources de la même categorie
Commentaires et avis
|
Derniers Blogs
GESTION D'EXCEPTION AVEC LES TASKSGESTION D'EXCEPTION AVEC LES TASKS par richardc
Nous avons vu dans un précédent article comment utiliser Task pour effectuer des opérations dans un autre thread.
Malheureusement, comme tout le monde n'est pas parfait, il se peut que cette exécution se passe mal et qu'une exception se produise.
La...
Cliquez pour lire la suite de l'article par richardc DéMARRONS AVEC LES TASKSDéMARRONS AVEC LES TASKS par richardc
Que vous le vouliez ou non, le développement multi-tâche est maintenant une obligation pour toute nouvelle application. Il est donc vital d'en comprendre les mécanismes et de s'y mettre le plus tôt possible.
En attendant le .NET Framework 4.5 avec le...
Cliquez pour lire la suite de l'article par richardc SLIDE & DéMO TECHDAYS 2012 - FAST & FURIOUS XAML APPSSLIDE & DéMO TECHDAYS 2012 - FAST & FURIOUS XAML APPS par Vko
Retrouvez les slides et les démo de ma session Fast & Furious XAML Apps. A ceux qui se posent la question : "est-ce que le code de la DataGrid est disponible?", je vous répondrais "pas encore". Je vais mettre en place un projet codeplex pour part...
Cliquez pour lire la suite de l'article par Vko XNA IS DEAD!XNA IS DEAD! par richardc
Depuis la semaine dernière (et grâce aux TechDays 2012), je me penche activement sur la nouvelle version de Windows, aka Windows 8. Vous me direz, il était temps puisque la première preview date de Septembre dernier.
OK. Remarquez, on n'en est qu'aux...
Cliquez pour lire la suite de l'article par richardc TECHDAYS PARIS 2012 : WINDOWS SERVER "8" QUOI DE 9 !TECHDAYS PARIS 2012 : WINDOWS SERVER "8" QUOI DE 9 ! par ROMELARD Fabrice
Speakers: Fabrice Meillon et Stanislas Quastana Cette session est basée entièrement sur celle donnée lors de la BUILD cet hiver. Il n'y a pas d'ajout d'information en rapport avec cet évènement passé. Windows 8 Server sera intégralem...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice
Logiciels
DocTranslate (V3.1.0.0)DOCTRANSLATE (V3.1.0.0)DocTranslate est un traducteur de document Microsoft Word, PowerPoint et Excel. Il permet d'autom... Cliquez pour télécharger DocTranslate Tribler (2012)TRIBLER (2012)Tribler est un client pair à pair (P2P/Peer-to-Peer) open source avec la capacité de regarder des... Cliquez pour télécharger Tribler OneSwarm (2012)ONESWARM (2012)Le peer-to-peer qui protège votre vie privée, c'est OneSwarm.
Ce logiciel de peer-to-peer crypté... Cliquez pour télécharger OneSwarm PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System
|