Tampon paramétrable

Bonjour,

Je cherche le moyen de mettre un tampon lors de la génération de nos plans en PDF, mais avec une donnée propre à chaque conversion.

Cet à dire que je souhaite pouvoir remplir un champ avec un texte ou nombre et que le tampon reprenne cette information.

Quelqu'un a t’il déjà fait cela ?

Bonjour;

Si vous voulez ce Tampon uniquement sur les PDF, je ne vois qu'une Macro pour faire ceci. (Je n'ai pas ce type de Macro en magasin pour l'instant mais elle ne me parait pas trop compliquée à realiser.)

Sinon en passant par les Annotations liée à une propriétés, ou via un bloc, c'est possible mais le Tampon sera visible dans Solidworks et toutes vos conversions.(pdf;dwg;dxf...) (sauf à exclure un claque particulier dans lequel se trouverai cette Annotation...)

3 « J'aime »

Merci pour votre réponse,

Je ne suis pas coutumier des macros et j'avoue en pas savoir pas comment faire. Je vais tacher de me renseigner.

Tu peux le faire par macro comme @MacLane vient de te l'expliquer.

Voici un exemple d'ajout d'annotation depuis la macro il restera à exporter en pdf exemple que tu trouvera facilement via une recherche.

Option Explicit

Dim swApp                       As SldWorks.SldWorks
Dim swModel                     As SldWorks.ModelDoc2
Dim swDraw                      As SldWorks.DrawingDoc
Dim swSketchBlockDef            As SldWorks.SketchBlockDefinition
Dim swBlockInst                 As SldWorks.SketchBlockInstance
Dim swSketchMgr                 As SldWorks.SketchManager
Dim swModelDocExt               As SldWorks.ModelDocExtension
Dim swSheet                     As SldWorks.Sheet
Dim mySheet                     As SldWorks.Sheet
Dim paperSize                   As swDwgPaperSizes_e
Dim myBlockDefinition           As Object
Dim vSheetNames                 As Variant
Dim bRet                        As Boolean
Dim i                           As Long
Dim swMathUtil                  As SldWorks.MathUtility
Dim swMathPoint                 As SldWorks.MathPoint
Dim width                       As Double
Dim height                      As Double
Dim nPt(2)                      As Double
Dim vPt                         As Variant
Dim posX                        As Double
Dim posY                        As Double
Dim nomDuBloc                   As String
Dim swTextFormat                As SldWorks.TextFormat
Public X                        As Double
Public Y                        As Double
Public str                      As String



 
Sub contactAlimentaire()
'On appelle la procédure et on place le texte comme argument
coordonnéeXY "Contact Alimentaire"
End Sub

Sub traçabilitéNuance()
'On appelle la procédure et on place le texte comme argument
coordonnéeXY "Traçabilité Nuance"
End Sub
Sub traçabilitéNuanceEtContactAlimentaire()
'On appelle la procédure et on place le texte comme argument
coordonnéeXY "Traçabilité Nuance" + Chr(10) + "Contact Alimentaire"
End Sub

Sub coordonnéeXY(str As String)
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swDraw = swModel
    Set swSheet = swDraw.GetCurrentSheet
    vSheetNames = swDraw.GetSheetNames

    
    For i = 0 To UBound(vSheetNames)

        posX = 0.065       'modifier ici le décalage en X par rapport à l'angle en haut à gauche
        posY = 0.015      'modifier ici le décalage en Y par rapport à l'angle en haut à gauche
        swDraw.ActivateSheet (vSheetNames(i))
        Set mySheet = swDraw.GetCurrentSheet
        paperSize = mySheet.GetSize(width, height)
        posX = width - posX
        posY = height - posY
        insertionNote swModel, posX, posY, str
        swDraw.GraphicsRedraw2
        
    Next i
    swDraw.ActivateSheet (swSheet.GetName)
End Sub

Sub insertionNote(swModel As ModelDoc2, X As Double, Y As Double, monBloc As String)
    Dim myNote As Note
    Dim myAnnotation As Annotation
    Dim swTextFormat As SldWorks.TextFormat
    Dim boolstatus As Boolean
    Set myNote = swModel.InsertNote(monBloc)
    If Not myNote Is Nothing Then
        boolstatus = myNote.SetBalloon(4, 0)
        Set myAnnotation = myNote.GetAnnotation()
        If Not myAnnotation Is Nothing Then
            boolstatus = myAnnotation.SetPosition(X, Y, 0)
            Set swTextFormat = myAnnotation.GetTextFormat(1)
            swTextFormat.CharHeight = 0.004
            swTextFormat.Bold = True
            swTextFormat.Italic = True
            boolstatus = myAnnotation.SetTextFormat(1, False, swTextFormat)
        End If
    End If
    ListeCalque swDraw, myAnnotation
End Sub

Sub ListeCalque(swModel As DrawingDoc, myAnnotation As Annotation)
    Dim swLayerMgr As SldWorks.LayerMgr
    Dim vLayerArr As Variant
    Dim vLayer As Variant
    Dim swLayer As SldWorks.Layer
    Dim noteLayer As Integer
    Dim layerExist As Boolean
    Set swLayerMgr = swModel.GetLayerManager
    vLayerArr = swLayerMgr.GetLayerList
    For Each vLayer In vLayerArr
        Set swLayer = swLayerMgr.GetLayer(vLayer)
        If swLayer.Name = "NotesRouge" Then
            layerExist = True
        Else
            layerExist = False
        End If
    Next
    If layerExist = True Then
        myAnnotation.Layer = "NotesRouge"
    Else
        noteLayer = swLayerMgr.AddLayer("NotesRouge", "Calque pour les notes rouge", RGB(255, 0, 0), 0, 0)
        myAnnotation.Layer = "NotesRouge"
    End If
End Sub

Une autre solution est effectivement une modification de propriété @Maclane.

Pouir cela le plus simple pour toi c'est de créer une propriétée vide dans ton fond de plan que tu modifieras avec Intégration (utilitaire Visiativ auquel tu as accès via ton abonnement Mycadservice)  suivant une éventuelle règle et avec lequel tu peux également exporter en pdf et cela sans aucune connaissance en vba language des macros.

De plus ce lancement peut être fait à partir d'une liste de fichier

Aide Intégration:

https://help.visiativ.com/mycadtools/2020/fr/Integration.html

2 « J'aime »

Bonjour,

tes PDF sont'ils générés par une tache EPDM ?
Si oui il y a une option dans l'utilitaire pour ajouter un tampon

Bonjour, merci pour vos compléments d'informations.

Pierre S, oui ils sont générés via une tache et oui, tu peux ajouter un tampon, mais il faudrait qu'il soit paramétrable à souhait.