macro conversion dxf avec nom d'une propriété de pièce

Bonjour,

je voudrai modifier la macro ci dessous pour utiliser un propriété de la pièce comme nom de fichier DXF. (au lieu d'ajouter l'indice)

 

Pouvez vous m'aider, je ne connais pas la programmation des macro et j'ai 500 fichiers à traiter

 

 

Sub main()

Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc 'associe part au document en cours

If Part.GetType = swDocDRAWING Then 'verif type document

    Set swModExt = Part.Extension
    Set Prop = swModExt.CustomPropertyManager("")
    Part.ForceRebuild3 True

    Set swView = Part.GetFirstView
    'la première vue étant la feuille, passage à la suivante
    Set swView = swView.GetNextView
    'récupération de la pièce
    Set swModel = swView.ReferencedDocument
    Set swModExt = swModel.Extension
    
    
    'affectation de "Indice" à "Att"
    Dim RevTable As Object
    Set Prop = swModExt.CustomPropertyManager("")
    Set RevTable = Part.GetCurrentSheet.RevisionTable
    Set custpropmgr = Part.Extension.CustomPropertyManager("")
    Att = ""    'initialise la variable Ind
    Att = RevTable.Text(0, 0)
    'Att = Part.GetCustomInfoValue("", "Révision") 'recupere l'indice du plan
    'boolstatus = Prop.Get3("Indice", False, ValOut, Att)
    If Att = " " Then Att = ""
    If Att = "Indice" Then Att = ""
    
    'récupération du chemin complet
    swPathName = Part.GetPathName
    If swPathName = "" Then
        swApp.SendMsgToUser ("Le fichier de mise en plan n'est pas enregistré, veuillez le faire et recommencer")
        Exit Sub
    End If
    
    nomchemin = Mid(swPathName, 1, Len(swPathName) - 7)
    
    'enregistrement dxf
    swPathName = nomchemin & Att + ".dxf" ' ajoute _ind et.dxf"
    Set swModExt = Part.Extension
    Part.ViewZoomtofit2
    boolstatus = swModExt.SaveAs(swPathName, 0, 0, swExportPDFData, Errors, Warnings) 'sauvegarde en dxf
    
    'enregistrement pdf
    
    swPathName = nomchemin & Att + ".pdf" ' ajoute _ind et .pdf"
    Set swModExt = Part.Extension
    Part.ViewZoomtofit2
    boolstatus = swModExt.SaveAs(swPathName, 0, 0, swExportPDFData, Errors, Warnings) 'sauvegarde en pdf
    
    
    
    Else: swApp.SendMsgToUser ("Cette macro fonctionne uniquement avec une mise en plan")
    
End If

    
End Sub

 

Bonjour,

Le plus simple c'est d'utiliser l'outil BatchConverter de myCADtools

Tu as des règles de nommage qui correspondent à ton besoin.

 

Philippe

1 « J'aime »

Bonjour, 

Et de quelle propriétés s'agit-il ???

1 « J'aime »

bonjour,

le nom de fichier dxf et pdf doit correspondre à la propriété BIO

 

 

Bonjour,

Dans ta macro, tu remplaces les lignes :

'affectation de "Indice" à "Att"
Dim RevTable As Object
Set Prop = swModExt.CustomPropertyManager("")
Set RevTable = Part.GetCurrentSheet.RevisionTable
Set custpropmgr = Part.Extension.CustomPropertyManager("")
Att = ""    'initialise la variable Ind
Att = RevTable.Text(0, 0)
'Att = Part.GetCustomInfoValue("", "Révision") 'recupere l'indice du plan
'boolstatus = Prop.Get3("Indice", False, ValOut, Att)
If Att = " " Then Att = ""
If Att = "Indice" Then Att = ""

Par :

Set Prop = swModExt.CustomPropertyManager("")
Set custpropmgr = Part.Extension.CustomPropertyManager("")
Att = ""
Att = Part.GetCustomInfoValue("", "BIO")

Cordialement,

1 « J'aime »

Merci d'utiliser la balise Code à l'aide du bouton surligné :

Cela rend les postes bien plus lisible...


boutoncode.png
1 « J'aime »

Merci pour l'info remrem, je ne connaissais pas cette fonction ....

1 « J'aime »