Adjustable buffer

Hello

I'm looking for a way to put a stamp when generating our plans in PDF, but with a data specific to each conversion.

This means that I want to be able to fill in a field with a text or number and that the stamp includes this information.

Has anyone ever done this?

Hello;

If you want this stamp only on PDFs, I only see a Macro to do this. (I don't have this type of Macro in store for the moment but it doesn't seem too complicated to make.)

Otherwise by going through the Annotations linked to a property, or via a block, it is possible but the Stamp will be visible in Solidworks and all your conversions. (pdf; DWG; dxf...) (unless we exclude a particular slap in the face in which this Annotation will be found...)

3 Likes

Thank you for your answer,

I'm not used to macros and I admit I don't know how to do it. I will try to find out.

You can do it by macro as @MacLane just explained to you.

Here is an example of adding annotation from the macro, it will remain to be exported in pdf, example that you will easily find via a search.

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

Another solution is indeed a change of ownership @Maclane.

To do this, the easiest way for you is to create an empty property in your basemap that you will modify with Integration (Visiativ utility that you have access to via your Mycadservice subscription)  according to a possible rule and with which you can also export in pdf and this without any knowledge of vba language of macros.

Moreover, this launch can be done from a file list

Integration Help:

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

2 Likes

Hello

Are your PDFs generated by an EPDM job?
If yes there is an option in the utility to add a buffer

Hello, thank you for your additional information.

Pierre S, yes they are generated via a stain and yes, you can add a stamp, but it would have to be configurable as desired.