OnPrint DrawingDocument event

OnPrint DrawingDocument event

gustavo.cassel
Advocate Advocate
167 Views
1 Reply
Message 1 of 2

OnPrint DrawingDocument event

gustavo.cassel
Advocate
Advocate

Hi,

I've tried to find a OnPrintEvent listener but i think that inventor doesn't have one.

It would be nice to have something like this.

I want a way to "block" users from manual printing documents.

To force them to use my program, to successfully create the printing log's and to fulfill all info needed in the drawing easily.

 

Best regards,

0 Likes
168 Views
1 Reply
Reply (1)
Message 2 of 2

Frederick_Law
Mentor
Mentor

It does not exist.

Replace the print command with your command and call it to actually print.

https://github.com/Pineapple-RX93/PrintDate-2018

 

 

    Public Sub ReplaceButton(app As Application)

      Dim controlDefs As ControlDefinitions
      Dim controlDef As ControlDefinition
      Dim parentCtrl As CommandControl
      Dim targetCtrl As CommandControl
      Dim cmdCtrl As CommandControl
      Dim oQAT As CommandControls
      Dim FoundCount As Integer = 0
      Dim OldShortCut As String

      'MsgBox("Start Replace Button")
      controlDefs = app.CommandManager.ControlDefinitions
      For Each controlDef In app.CommandManager.ControlDefinitions
        If (controlDef.InternalName = "AppFilePrintCmd") Then
          IVPrintButtonDef = controlDef
          FoundCount += 1
          'MsgBox("Found Print")
        ElseIf (controlDef.InternalName = "AppFilePrintPreviewCmd") Then
          IVPrintPreviewButtonDef = controlDef
          FoundCount += 1
          'MsgBox("Found Print Preview")
        End If
        If FoundCount = 2 Then
          Exit For
        End If
      Next
      If FoundCount < 2 Then
        'MsgBox("No button found")
      End If

      'MsgBox("Create PrintDate Button")
      PrintButtonDef = controlDefs.AddButtonDefinition(IVPrintButtonDef.DisplayName,
          "AppFilePrintDateCmd",
          CommandTypesEnum.kFilePropertyEditCmdType,
          IVPrintButtonDef.ClientId,
          IVPrintButtonDef.DescriptionText,
          IVPrintButtonDef.ToolTipText,
          IVPrintButtonDef.StandardIcon,
          IVPrintButtonDef.LargeIcon)

      'MsgBox("Clear Old Override")
      OldShortCut = IVPrintButtonDef.OverrideShortcut
      IVPrintButtonDef.OverrideShortcut = ""

      'MsgBox("Set Override")
      PrintButtonDef.OverrideShortcut = OldShortCut

      'MsgBox("Create PrintDatePreview Button")
      PrintPreviewButtonDef = controlDefs.AddButtonDefinition(IVPrintPreviewButtonDef.DisplayName,
          "AppFilePrintDatePreviewCmd",
          CommandTypesEnum.kFilePropertyEditCmdType,
          IVPrintPreviewButtonDef.ClientId,
          IVPrintPreviewButtonDef.DescriptionText,
          IVPrintPreviewButtonDef.ToolTipText,
          IVPrintPreviewButtonDef.StandardIcon,
          IVPrintPreviewButtonDef.LargeIcon)

      'Add Button to FileBrowerControl, hide original Button
      'MsgBox("Adding to File Brower")
      parentCtrl = app.UserInterfaceManager.FileBrowserControls("AppFilePrintCmd")
      targetCtrl = parentCtrl.ChildControls("AppFilePrintCmd")
      cmdCtrl = parentCtrl.ChildControls.AddButton(PrintButtonDef, False, True,
                                                   IVPrintButtonDef.InternalName, True)
      targetCtrl.Visible = False
      targetCtrl = parentCtrl.ChildControls("AppFilePrintPreviewCmd")
      cmdCtrl = parentCtrl.ChildControls.AddButton(PrintPreviewButtonDef, False, True,
                                                   IVPrintPreviewButtonDef.InternalName, True)
      targetCtrl.Visible = False
      'MsgBox("Added to File Brower")

      'Add Button to Drawing.QuickAccessToolbar, hide original Button
      'MsgBox("Adding to QAT")
      oQAT = app.UserInterfaceManager.Ribbons.Item("Drawing").QuickAccessControls
      targetCtrl = oQAT.Item(IVPrintButtonDef.InternalName)
      cmdCtrl = oQAT.AddButton(PrintButtonDef, False, True, IVPrintButtonDef.InternalName, True)
      targetCtrl.Visible = False
      'MsgBox("Added to QAT")

    End Sub

    Private Sub PrintButtonDef_OnExecute(Context As NameValueMap) Handles PrintButtonDef.OnExecute
      SetProperties()
      IVPrintButtonDef.Execute()
    End Sub

    Private Sub PrintPreviewButtonDef_OnExecute(Context As NameValueMap) Handles PrintPreviewButtonDef.OnExecute
      SetProperties()
      IVPrintPreviewButtonDef.Execute()
    End Sub

 

 

PS

Does this consider man-in-the-middle attack? 🤔